Lines Matching refs:Ops
66 static void PrintOps(Instruction *I, const SmallVectorImpl<ValueEntry> &Ops) { in PrintOps() argument
69 << *Ops[0].Op->getType() << '\t'; in PrintOps()
70 for (unsigned i = 0, e = Ops.size(); i != e; ++i) { in PrintOps()
72 Ops[i].Op->printAsOperand(dbgs(), false, M); in PrintOps()
73 dbgs() << ", #" << Ops[i].Rank << "] "; in PrintOps()
170 void RewriteExprTree(BinaryOperator *I, SmallVectorImpl<ValueEntry> &Ops);
172 SmallVectorImpl<ValueEntry> &Ops);
173 Value *OptimizeAdd(Instruction *I, SmallVectorImpl<ValueEntry> &Ops);
174 Value *OptimizeXor(Instruction *I, SmallVectorImpl<ValueEntry> &Ops);
179 bool collectMultiplyFactors(SmallVectorImpl<ValueEntry> &Ops,
183 Value *OptimizeMul(BinaryOperator *I, SmallVectorImpl<ValueEntry> &Ops);
535 SmallVectorImpl<RepeatedValue> &Ops) { in LinearizeExprTree() argument
695 Ops.push_back(std::make_pair(V, Weight)); in LinearizeExprTree()
701 if (Ops.empty()) { in LinearizeExprTree()
704 Ops.emplace_back(Identity, APInt(Bitwidth, 1)); in LinearizeExprTree()
713 SmallVectorImpl<ValueEntry> &Ops) { in RewriteExprTree() argument
714 assert(Ops.size() > 1 && "Single values should be used directly!"); in RewriteExprTree()
742 for (unsigned i = 0, e = Ops.size(); i != e; ++i) in RewriteExprTree()
743 NotRewritable.insert(Ops[i].Op); in RewriteExprTree()
753 if (i+2 == Ops.size()) { in RewriteExprTree()
754 Value *NewLHS = Ops[i].Op; in RewriteExprTree()
755 Value *NewRHS = Ops[i+1].Op; in RewriteExprTree()
799 Value *NewRHS = Ops[i].Op; in RewriteExprTree()
1057 static unsigned FindInOperandList(SmallVectorImpl<ValueEntry> &Ops, unsigned i, in FindInOperandList() argument
1059 unsigned XRank = Ops[i].Rank; in FindInOperandList()
1060 unsigned e = Ops.size(); in FindInOperandList()
1061 for (unsigned j = i+1; j != e && Ops[j].Rank == XRank; ++j) { in FindInOperandList()
1062 if (Ops[j].Op == X) in FindInOperandList()
1064 if (Instruction *I1 = dyn_cast<Instruction>(Ops[j].Op)) in FindInOperandList()
1070 for (unsigned j = i-1; j != ~0U && Ops[j].Rank == XRank; --j) { in FindInOperandList()
1071 if (Ops[j].Op == X) in FindInOperandList()
1073 if (Instruction *I1 = dyn_cast<Instruction>(Ops[j].Op)) in FindInOperandList()
1084 SmallVectorImpl<WeakVH> &Ops){ in EmitAddTreeOfValues() argument
1085 if (Ops.size() == 1) return Ops.back(); in EmitAddTreeOfValues()
1087 Value *V1 = Ops.back(); in EmitAddTreeOfValues()
1088 Ops.pop_back(); in EmitAddTreeOfValues()
1089 Value *V2 = EmitAddTreeOfValues(I, Ops); in EmitAddTreeOfValues()
1172 const SmallVectorImpl<ValueEntry> &Ops) { in FindSingleUseMultiplyFactors() argument
1180 FindSingleUseMultiplyFactors(BO->getOperand(1), Factors, Ops); in FindSingleUseMultiplyFactors()
1181 FindSingleUseMultiplyFactors(BO->getOperand(0), Factors, Ops); in FindSingleUseMultiplyFactors()
1188 SmallVectorImpl<ValueEntry> &Ops) { in OptimizeAndOrXor() argument
1191 for (unsigned i = 0, e = Ops.size(); i != e; ++i) { in OptimizeAndOrXor()
1193 assert(i < Ops.size()); in OptimizeAndOrXor()
1194 if (BinaryOperator::isNot(Ops[i].Op)) { // Cannot occur for ^. in OptimizeAndOrXor()
1195 Value *X = BinaryOperator::getNotArgument(Ops[i].Op); in OptimizeAndOrXor()
1196 unsigned FoundX = FindInOperandList(Ops, i, X); in OptimizeAndOrXor()
1208 assert(i < Ops.size()); in OptimizeAndOrXor()
1209 if (i+1 != Ops.size() && Ops[i+1].Op == Ops[i].Op) { in OptimizeAndOrXor()
1212 Ops.erase(Ops.begin()+i); in OptimizeAndOrXor()
1221 return Constant::getNullValue(Ops[0].Op->getType()); in OptimizeAndOrXor()
1224 Ops.erase(Ops.begin()+i, Ops.begin()+i+2); in OptimizeAndOrXor()
1371 SmallVectorImpl<ValueEntry> &Ops) { in OptimizeXor() argument
1372 if (Value *V = OptimizeAndOrXor(Instruction::Xor, Ops)) in OptimizeXor()
1375 if (Ops.size() == 1) in OptimizeXor()
1380 Type *Ty = Ops[0].Op->getType(); in OptimizeXor()
1384 for (unsigned i = 0, e = Ops.size(); i != e; ++i) { in OptimizeXor()
1385 Value *V = Ops[i].Op; in OptimizeXor()
1451 Ops.clear(); in OptimizeXor()
1457 Ops.push_back(VE); in OptimizeXor()
1462 Ops.push_back(VE); in OptimizeXor()
1464 int Sz = Ops.size(); in OptimizeXor()
1466 return Ops.back().Op; in OptimizeXor()
1480 SmallVectorImpl<ValueEntry> &Ops) { in OptimizeAdd() argument
1486 for (unsigned i = 0, e = Ops.size(); i != e; ++i) { in OptimizeAdd()
1487 Value *TheOp = Ops[i].Op; in OptimizeAdd()
1491 if (i+1 != Ops.size() && Ops[i+1].Op == TheOp) { in OptimizeAdd()
1495 Ops.erase(Ops.begin()+i); in OptimizeAdd()
1497 } while (i != Ops.size() && Ops[i].Op == TheOp); in OptimizeAdd()
1514 if (Ops.empty()) in OptimizeAdd()
1520 Ops.insert(Ops.begin(), ValueEntry(getRank(Mul), Mul)); in OptimizeAdd()
1523 e = Ops.size(); in OptimizeAdd()
1538 unsigned FoundX = FindInOperandList(Ops, i, X); in OptimizeAdd()
1543 if (Ops.size() == 2 && in OptimizeAdd()
1548 if (Ops.size() == 2 && BinaryOperator::isNot(TheOp)) in OptimizeAdd()
1551 Ops.erase(Ops.begin()+i); in OptimizeAdd()
1556 Ops.erase(Ops.begin()+FoundX); in OptimizeAdd()
1564 Ops.insert(Ops.end(), ValueEntry(getRank(V), V)); in OptimizeAdd()
1580 for (unsigned i = 0, e = Ops.size(); i != e; ++i) { in OptimizeAdd()
1582 isReassociableOp(Ops[i].Op, Instruction::Mul, Instruction::FMul); in OptimizeAdd()
1588 FindSingleUseMultiplyFactors(BOp, Factors, Ops); in OptimizeAdd()
1650 for (unsigned i = 0; i != Ops.size(); ++i) { in OptimizeAdd()
1653 isReassociableOp(Ops[i].Op, Instruction::Mul, Instruction::FMul); in OptimizeAdd()
1657 if (Value *V = RemoveFactorFromExpression(Ops[i].Op, MaxOccVal)) { in OptimizeAdd()
1660 for (unsigned j = Ops.size(); j != i;) { in OptimizeAdd()
1662 if (Ops[j].Op == Ops[i].Op) { in OptimizeAdd()
1664 Ops.erase(Ops.begin()+j); in OptimizeAdd()
1694 if (Ops.empty()) in OptimizeAdd()
1700 Ops.insert(Ops.begin(), ValueEntry(getRank(V2), V2)); in OptimizeAdd()
1717 bool Reassociate::collectMultiplyFactors(SmallVectorImpl<ValueEntry> &Ops, in collectMultiplyFactors() argument
1722 for (unsigned Idx = 1, Size = Ops.size(); Idx < Size; ++Idx) { in collectMultiplyFactors()
1723 Value *Op = Ops[Idx-1].Op; in collectMultiplyFactors()
1727 for (; Idx < Size && Ops[Idx].Op == Op; ++Idx) in collectMultiplyFactors()
1743 for (unsigned Idx = 1; Idx < Ops.size(); ++Idx) { in collectMultiplyFactors()
1744 Value *Op = Ops[Idx-1].Op; in collectMultiplyFactors()
1748 for (; Idx < Ops.size() && Ops[Idx].Op == Op; ++Idx) in collectMultiplyFactors()
1757 Ops.erase(Ops.begin()+Idx, Ops.begin()+Idx+Count); in collectMultiplyFactors()
1770 SmallVectorImpl<Value*> &Ops) { in buildMultiplyTree() argument
1771 if (Ops.size() == 1) in buildMultiplyTree()
1772 return Ops.back(); in buildMultiplyTree()
1774 Value *LHS = Ops.pop_back_val(); in buildMultiplyTree()
1777 LHS = Builder.CreateMul(LHS, Ops.pop_back_val()); in buildMultiplyTree()
1779 LHS = Builder.CreateFMul(LHS, Ops.pop_back_val()); in buildMultiplyTree()
1780 } while (!Ops.empty()); in buildMultiplyTree()
1847 SmallVectorImpl<ValueEntry> &Ops) { in OptimizeMul() argument
1850 if (Ops.size() < 4) in OptimizeMul()
1857 if (!collectMultiplyFactors(Ops, Factors)) in OptimizeMul()
1862 if (Ops.empty()) in OptimizeMul()
1866 Ops.insert(std::lower_bound(Ops.begin(), Ops.end(), NewEntry), NewEntry); in OptimizeMul()
1871 SmallVectorImpl<ValueEntry> &Ops) { in OptimizeExpression() argument
1876 while (!Ops.empty() && isa<Constant>(Ops.back().Op)) { in OptimizeExpression()
1877 Constant *C = cast<Constant>(Ops.pop_back_val().Op); in OptimizeExpression()
1881 if (Ops.empty()) in OptimizeExpression()
1890 Ops.push_back(ValueEntry(0, Cst)); in OptimizeExpression()
1893 if (Ops.size() == 1) return Ops[0].Op; in OptimizeExpression()
1897 unsigned NumOps = Ops.size(); in OptimizeExpression()
1902 if (Value *Result = OptimizeAndOrXor(Opcode, Ops)) in OptimizeExpression()
1907 if (Value *Result = OptimizeXor(I, Ops)) in OptimizeExpression()
1913 if (Value *Result = OptimizeAdd(I, Ops)) in OptimizeExpression()
1919 if (Value *Result = OptimizeMul(I, Ops)) in OptimizeExpression()
1924 if (Ops.size() != NumOps) in OptimizeExpression()
1925 return OptimizeExpression(I, Ops); in OptimizeExpression()
1932 SmallVector<Value*, 8> Ops(I->op_begin(), I->op_end()); in EraseInst() local
1939 for (unsigned i = 0, e = Ops.size(); i != e; ++i) in EraseInst()
1940 if (Instruction *Op = dyn_cast<Instruction>(Ops[i])) { in EraseInst()
2162 SmallVector<ValueEntry, 8> Ops; in ReassociateExpression() local
2163 Ops.reserve(Tree.size()); in ReassociateExpression()
2166 Ops.append(E.second.getZExtValue(), in ReassociateExpression()
2170 DEBUG(dbgs() << "RAIn:\t"; PrintOps(I, Ops); dbgs() << '\n'); in ReassociateExpression()
2178 std::stable_sort(Ops.begin(), Ops.end()); in ReassociateExpression()
2182 if (Value *V = OptimizeExpression(I, Ops)) { in ReassociateExpression()
2204 isa<ConstantInt>(Ops.back().Op) && in ReassociateExpression()
2205 cast<ConstantInt>(Ops.back().Op)->isAllOnesValue()) { in ReassociateExpression()
2206 ValueEntry Tmp = Ops.pop_back_val(); in ReassociateExpression()
2207 Ops.insert(Ops.begin(), Tmp); in ReassociateExpression()
2211 isa<ConstantFP>(Ops.back().Op) && in ReassociateExpression()
2212 cast<ConstantFP>(Ops.back().Op)->isExactlyValue(-1.0)) { in ReassociateExpression()
2213 ValueEntry Tmp = Ops.pop_back_val(); in ReassociateExpression()
2214 Ops.insert(Ops.begin(), Tmp); in ReassociateExpression()
2218 DEBUG(dbgs() << "RAOut:\t"; PrintOps(I, Ops); dbgs() << '\n'); in ReassociateExpression()
2220 if (Ops.size() == 1) { in ReassociateExpression()
2221 if (Ops[0].Op == I) in ReassociateExpression()
2227 I->replaceAllUsesWith(Ops[0].Op); in ReassociateExpression()
2228 if (Instruction *OI = dyn_cast<Instruction>(Ops[0].Op)) in ReassociateExpression()
2236 RewriteExprTree(I, Ops); in ReassociateExpression()