Lines Matching refs:BinaryOperator

128 static BinaryOperator *isReassociableOp(Value *V, unsigned Opcode) {  in isReassociableOp()
133 return cast<BinaryOperator>(V); in isReassociableOp()
137 static BinaryOperator *isReassociableOp(Value *V, unsigned Opcode1, in isReassociableOp()
144 return cast<BinaryOperator>(V); in isReassociableOp()
191 if (!BinaryOperator::isNot(I) && !BinaryOperator::isNeg(I) && in getRank()
192 !BinaryOperator::isFNeg(I)) in getRank()
202 assert(isa<BinaryOperator>(I) && "Expected binary operator."); in canonicalizeOperands()
214 cast<BinaryOperator>(I)->swapOperands(); in canonicalizeOperands()
217 static BinaryOperator *CreateAdd(Value *S1, Value *S2, const Twine &Name, in CreateAdd()
220 return BinaryOperator::CreateAdd(S1, S2, Name, InsertBefore); in CreateAdd()
222 BinaryOperator *Res = in CreateAdd()
223 BinaryOperator::CreateFAdd(S1, S2, Name, InsertBefore); in CreateAdd()
229 static BinaryOperator *CreateMul(Value *S1, Value *S2, const Twine &Name, in CreateMul()
232 return BinaryOperator::CreateMul(S1, S2, Name, InsertBefore); in CreateMul()
234 BinaryOperator *Res = in CreateMul()
235 BinaryOperator::CreateFMul(S1, S2, Name, InsertBefore); in CreateMul()
241 static BinaryOperator *CreateNeg(Value *S1, const Twine &Name, in CreateNeg()
244 return BinaryOperator::CreateNeg(S1, Name, InsertBefore); in CreateNeg()
246 BinaryOperator *Res = BinaryOperator::CreateFNeg(S1, Name, InsertBefore); in CreateNeg()
253 static BinaryOperator *LowerNegateToMultiply(Instruction *Neg) { in LowerNegateToMultiply()
258 BinaryOperator *Res = CreateMul(Neg->getOperand(1), NegOne, "", Neg, Neg); in LowerNegateToMultiply()
433 static bool LinearizeExprTree(BinaryOperator *I, in LinearizeExprTree()
451 SmallVector<std::pair<BinaryOperator*, APInt>, 8> Worklist; // (Op, Weight) in LinearizeExprTree()
478 std::pair<BinaryOperator*, APInt> P = Worklist.pop_back_val(); in LinearizeExprTree()
489 if (BinaryOperator *BO = isReassociableOp(Op, Opcode)) { in LinearizeExprTree()
528 if (BinaryOperator *BO = isReassociableOp(Op, Opcode)) { in LinearizeExprTree()
559 if (BinaryOperator *BO = dyn_cast<BinaryOperator>(Op)) in LinearizeExprTree()
560 if ((Opcode == Instruction::Mul && BinaryOperator::isNeg(BO)) || in LinearizeExprTree()
561 (Opcode == Instruction::FMul && BinaryOperator::isFNeg(BO))) { in LinearizeExprTree()
611 void ReassociatePass::RewriteExprTree(BinaryOperator *I, in RewriteExprTree()
626 SmallVector<BinaryOperator*, 8> NodesToRewrite; in RewriteExprTree()
628 BinaryOperator *Op = I; in RewriteExprTree()
647 BinaryOperator *ExpressionChanged = nullptr; in RewriteExprTree()
676 BinaryOperator *BO = isReassociableOp(OldLHS, Opcode); in RewriteExprTree()
682 BinaryOperator *BO = isReassociableOp(OldRHS, Opcode); in RewriteExprTree()
707 BinaryOperator *BO = isReassociableOp(Op->getOperand(1), Opcode); in RewriteExprTree()
721 BinaryOperator *BO = isReassociableOp(Op->getOperand(0), Opcode); in RewriteExprTree()
734 BinaryOperator *NewOp; in RewriteExprTree()
737 NewOp = BinaryOperator::Create(Instruction::BinaryOps(Opcode), in RewriteExprTree()
771 ExpressionChanged = cast<BinaryOperator>(*ExpressionChanged->user_begin()); in RewriteExprTree()
805 if (BinaryOperator *I = in NegateValue()
832 if (!BinaryOperator::isNeg(U) && !BinaryOperator::isFNeg(U)) in NegateValue()
839 BinaryOperator *TheNeg = cast<BinaryOperator>(U); in NegateValue()
869 BinaryOperator *NewNeg = CreateNeg(V, V->getName() + ".neg", BI, BI); in NegateValue()
877 if (BinaryOperator::isNeg(Sub) || BinaryOperator::isFNeg(Sub)) in ShouldBreakUpSubtract()
905 static BinaryOperator *
914 BinaryOperator *New = CreateAdd(Sub->getOperand(0), NegVal, "", Sub, Sub); in BreakUpSubtract()
929 static BinaryOperator *ConvertShiftToMul(Instruction *Shl) { in ConvertShiftToMul()
933 BinaryOperator *Mul = in ConvertShiftToMul()
934 BinaryOperator::CreateMul(Shl->getOperand(0), MulCst, "", Shl); in ConvertShiftToMul()
945 bool NSW = cast<BinaryOperator>(Shl)->hasNoSignedWrap(); in ConvertShiftToMul()
946 bool NUW = cast<BinaryOperator>(Shl)->hasNoUnsignedWrap(); in ConvertShiftToMul()
996 BinaryOperator *BO = isReassociableOp(V, Instruction::Mul, Instruction::FMul); in RemoveFactorFromExpression()
1072 BinaryOperator *BO = isReassociableOp(V, Instruction::Mul, Instruction::FMul); in FindSingleUseMultiplyFactors()
1093 if (BinaryOperator::isNot(Ops[i].Op)) { // Cannot occur for ^. in OptimizeAndOrXor()
1094 Value *X = BinaryOperator::getNotArgument(Ops[i].Op); in OptimizeAndOrXor()
1142 I = BinaryOperator::CreateAnd(Opnd, ConstantInt::get(Ctx, ConstOpnd), in createAndInstr()
1440 if (!BinaryOperator::isNeg(TheOp) && !BinaryOperator::isFNeg(TheOp) && in OptimizeAdd()
1441 !BinaryOperator::isNot(TheOp)) in OptimizeAdd()
1445 if (BinaryOperator::isNeg(TheOp) || BinaryOperator::isFNeg(TheOp)) in OptimizeAdd()
1446 X = BinaryOperator::getNegArgument(TheOp); in OptimizeAdd()
1447 else if (BinaryOperator::isNot(TheOp)) in OptimizeAdd()
1448 X = BinaryOperator::getNotArgument(TheOp); in OptimizeAdd()
1456 (BinaryOperator::isNeg(TheOp) || BinaryOperator::isFNeg(TheOp))) in OptimizeAdd()
1460 if (Ops.size() == 2 && BinaryOperator::isNot(TheOp)) in OptimizeAdd()
1474 if (BinaryOperator::isNot(TheOp)) { in OptimizeAdd()
1493 BinaryOperator *BOp = in OptimizeAdd()
1558 ? BinaryOperator::CreateAdd(MaxOccVal, MaxOccVal) in OptimizeAdd()
1559 : BinaryOperator::CreateFAdd(MaxOccVal, MaxOccVal); in OptimizeAdd()
1564 BinaryOperator *BOp = in OptimizeAdd()
1764 Value *ReassociatePass::OptimizeMul(BinaryOperator *I, in OptimizeMul()
1788 Value *ReassociatePass::OptimizeExpression(BinaryOperator *I, in OptimizeExpression()
1916 if (!isa<BinaryOperator>(User) || !User->hasNUsesOrMore(1)) in canonicalizeNegConstExpr()
1936 cast<BinaryOperator>(User)->swapOperands(); in canonicalizeNegConstExpr()
1940 BinaryOperator *NI; in canonicalizeNegConstExpr()
1945 NI = BinaryOperator::CreateFSub(Op0, Op1); in canonicalizeNegConstExpr()
1949 NI = BinaryOperator::CreateFAdd(Op0, Op1); in canonicalizeNegConstExpr()
1967 if (!isa<BinaryOperator>(I)) in OptimizeInst()
2019 } else if (BinaryOperator::isNeg(I)) { in OptimizeInst()
2029 if (BinaryOperator *Tmp = dyn_cast<BinaryOperator>(U)) in OptimizeInst()
2043 } else if (BinaryOperator::isFNeg(I)) { in OptimizeInst()
2053 if (BinaryOperator *Tmp = dyn_cast<BinaryOperator>(U)) in OptimizeInst()
2065 BinaryOperator *BO = cast<BinaryOperator>(I); in OptimizeInst()
2092 void ReassociatePass::ReassociateExpression(BinaryOperator *I) { in ReassociateExpression()