Lines Matching refs:Value
55 Value *Op;
56 ValueEntry(unsigned R, Value *O) : Rank(R), Op(O) {}
82 Value *Base;
85 Factor(Value *Base, unsigned Power) : Base(Base), Power(Power) {}
112 XorOpnd(Value *V);
116 Value *getValue() const { return OrigVal; }
117 Value *getSymbolicPart() const { return SymbolicPart; }
124 // Sort the XorOpnd-Pointer in ascending order of symbolic-value-rank.
126 // 1) Cluster together the operands sharing the same symbolic-value.
127 // 2) Operand having smaller symbolic-value-rank is permuted earlier, which
139 Value *OrigVal;
140 Value *SymbolicPart;
150 DenseMap<AssertingVH<Value>, unsigned> ValueRankMap;
167 unsigned getRank(Value *V);
171 Value *OptimizeExpression(BinaryOperator *I,
173 Value *OptimizeAdd(Instruction *I, SmallVectorImpl<ValueEntry> &Ops);
174 Value *OptimizeXor(Instruction *I, SmallVectorImpl<ValueEntry> &Ops);
176 Value *&Res);
178 APInt &ConstOpnd, Value *&Res);
181 Value *buildMinimalMultiplyDAG(IRBuilder<> &Builder,
183 Value *OptimizeMul(BinaryOperator *I, SmallVectorImpl<ValueEntry> &Ops);
184 Value *RemoveFactorFromExpression(Value *V, Value *Factor);
191 XorOpnd::XorOpnd(Value *V) {
199 Value *V0 = I->getOperand(0);
200 Value *V1 = I->getOperand(1);
227 static BinaryOperator *isReassociableOp(Value *V, unsigned Opcode) {
236 static BinaryOperator *isReassociableOp(Value *V, unsigned Opcode1,
271 unsigned Reassociate::getRank(Value *V) {
284 // cannot be loops in the value graph that do not go through PHI nodes.
306 Value *LHS = I->getOperand(0);
307 Value *RHS = I->getOperand(1);
318 static BinaryOperator *CreateAdd(Value *S1, Value *S2, const Twine &Name,
319 Instruction *InsertBefore, Value *FlagsOp) {
330 static BinaryOperator *CreateMul(Value *S1, Value *S2, const Twine &Name,
331 Instruction *InsertBefore, Value *FlagsOp) {
342 static BinaryOperator *CreateNeg(Value *S1, const Twine &Name,
343 Instruction *InsertBefore, Value *FlagsOp) {
435 /// CM - The value of Carmichael's lambda function.
458 typedef std::pair<Value*, APInt> RepeatedValue;
474 /// changes it makes may well be destructive, changing the value computed by 'I'
559 // X = A + B, the value X has two uses (by I) that are in the expression. If
561 // X to be a leaf, and won't analyze it further. When we first visit a value,
564 // uses of the value from inside the expression. If all uses turn out to be
565 // from within the expression (and the value is a binary operator of the right
566 // kind) then the value is no longer considered to be a leaf, and its operands
571 typedef DenseMap<Value*, APInt> LeafMap;
573 SmallVector<Value*, 8> LeafOrder; // Ensure deterministic leaf output order.
576 SmallPtrSet<Value*, 8> Visited; // For sanity checking the iteration scheme.
583 Value *Op = I->getOperand(OpIdx);
603 // This value has uses not accounted for by the expression, so it is
638 // then it is not safe to modify the value.
644 Leaves.erase(It); // Since the value may be morphed below.
647 // At this point we have a value which, first of all, is not a binary
674 assert(!isReassociableOp(Op, Opcode) && "Value was morphed?");
683 Value *V = LeafOrder[i];
700 // in both cases the weight reduces to 0 causing the value to be skipped.
741 SmallPtrSet<Value*, 8> NotRewritable;
754 Value *NewLHS = Ops[i].Op;
755 Value *NewRHS = Ops[i+1].Op;
756 Value *OldLHS = Op->getOperand(0);
757 Value *OldRHS = Op->getOperand(1);
799 Value *NewRHS = Ops[i].Op;
881 /// that computes the negative version of the value specified. The negative
882 /// version of the value is returned, and BI is left pointing at the instruction
887 static Value *NegateValue(Value *V, Instruction *BI,
938 // non-instruction value) or right after the definition. These negates will
968 // Insert a 'neg' instruction that subtracts the value from zero to get the
987 Value *V0 = Sub->getOperand(0);
991 Value *V1 = Sub->getOperand(1);
995 Value *VB = Sub->user_back();
1011 // Calculate the negative value of Operand 1 of the sub instruction,
1014 Value *NegVal = NegateValue(Sub->getOperand(1), Sub, ToRedo);
1058 Value *X) {
1083 static Value *EmitAddTreeOfValues(Instruction *I,
1087 Value *V1 = Ops.back();
1089 Value *V2 = EmitAddTreeOfValues(I, Ops);
1096 Value *Reassociate::RemoveFactorFromExpression(Value *V, Value *Factor) {
1170 static void FindSingleUseMultiplyFactors(Value *V,
1171 SmallVectorImpl<Value*> &Factors,
1185 /// This optimizes based on identities. If it can be reduced to a single Value,
1187 static Value *OptimizeAndOrXor(unsigned Opcode,
1195 Value *X = BinaryOperator::getNotArgument(Ops[i].Op);
1237 static Value *createAndInstr(Instruction *InsertBefore, Value *Opnd,
1254 // into "R ^ C", where C would be 0, and R is a symbolic value.
1261 APInt &ConstOpnd, Value *&Res) {
1274 Value *X = Opnd1->getSymbolicPart();
1289 // symbolic value.
1296 APInt &ConstOpnd, Value *&Res) {
1297 Value *X = Opnd1->getSymbolicPart();
1368 /// to a single Value, it is returned, otherwise the Ops list is mutated as
1370 Value *Reassociate::OptimizeXor(Instruction *I,
1372 if (Value *V = OptimizeAndOrXor(Instruction::Xor, Ops))
1385 Value *V = Ops[i].Op;
1403 // the same symbolic value cluster together. For instance, the input operand
1413 // The combined value
1414 Value *CV;
1433 // value, try to simplify "PrevOpnd ^ CurrOpnd ^ ConstOpnd"
1460 Value *C = ConstantInt::get(Ty->getContext(), ConstOpnd);
1477 /// optimizes based on identities. If it can be reduced to a single Value, it
1479 Value *Reassociate::OptimizeAdd(Instruction *I,
1487 Value *TheOp = Ops[i].Op;
1532 Value *X = nullptr;
1563 Value *V = Constant::getAllOnesValue(X->getType());
1574 DenseMap<Value*, unsigned> FactorOccurrences;
1579 Value *MaxOccVal = nullptr;
1586 // Compute all of the factors of this added value.
1587 SmallVector<Value*, 8> Factors;
1592 SmallPtrSet<Value*, 8> Duplicates;
1594 Value *Factor = Factors[i];
1604 // If Factor is a negative constant, add the negated value as a factor
1657 if (Value *V = RemoveFactorFromExpression(Ops[i].Op, MaxOccVal)) {
1675 Value *V = EmitAddTreeOfValues(I, NewMulOps);
1680 assert(NumAddedValues > 1 && "Each occurrence should contribute a value");
1706 /// \brief Build up a vector of value/power pairs factoring a product.
1723 Value *Op = Ops[Idx-1].Op;
1725 // Count the number of occurrences of this value.
1744 Value *Op = Ops[Idx-1].Op;
1746 // Count the number of occurrences of this value.
1769 static Value *buildMultiplyTree(IRBuilder<> &Builder,
1770 SmallVectorImpl<Value*> &Ops) {
1774 Value *LHS = Ops.pop_back_val();
1790 /// value.
1791 Value *Reassociate::buildMinimalMultiplyDAG(IRBuilder<> &Builder,
1794 SmallVector<Value *, 4> OuterProduct;
1805 SmallVector<Value *, 4> InnerProduct;
1812 // Reset the base value of the first factor to the new expression tree.
1814 Value *M = Factors[LastIdx].Base = buildMultiplyTree(Builder, InnerProduct);
1835 Value *SquareRoot = buildMinimalMultiplyDAG(Builder, Factors);
1842 Value *V = buildMultiplyTree(Builder, OuterProduct);
1846 Value *Reassociate::OptimizeMul(BinaryOperator *I,
1861 Value *V = buildMinimalMultiplyDAG(Builder, Factors);
1870 Value *Reassociate::OptimizeExpression(BinaryOperator *I,
1902 if (Value *Result = OptimizeAndOrXor(Opcode, Ops))
1907 if (Value *Result = OptimizeXor(I, Ops))
1913 if (Value *Result = OptimizeAdd(I, Ops))
1919 if (Value *Result = OptimizeMul(I, Ops))
1932 SmallVector<Value*, 8> Ops(I->op_begin(), I->op_end());
2004 Value *Op0 = User->getOperand(0);
2005 Value *Op1 = User->getOperand(1);
2182 if (Value *V = OptimizeExpression(I, Ops)) {