Lines Matching refs:Instruction

82 static void PrintOps(Instruction *I, const SmallVectorImpl<ValueEntry> &Ops) {  in PrintOps()
84 dbgs() << Instruction::getOpcodeName(I->getOpcode()) << " " in PrintOps()
127 Instruction *I = dyn_cast<Instruction>(V); in XorOpnd()
130 if (I && (I->getOpcode() == Instruction::Or || in XorOpnd()
131 I->getOpcode() == Instruction::And)) { in XorOpnd()
141 isOr = (I->getOpcode() == Instruction::Or); in XorOpnd()
156 static bool hasFPAssociativeFlags(Instruction *I) { in hasFPAssociativeFlags()
199 for (Instruction &I : *BB) in BuildRankMap()
206 Instruction *I = dyn_cast<Instruction>(V); in getRank()
236 void ReassociatePass::canonicalizeOperands(Instruction *I) { in canonicalizeOperands()
274 static Instruction *CreateNeg(Value *S1, const Twine &Name, in CreateNeg()
280 if (auto *FMFSource = dyn_cast<Instruction>(FlagsOp)) in CreateNeg()
287 static BinaryOperator *LowerNegateToMultiply(Instruction *Neg) { in LowerNegateToMultiply()
380 static bool LinearizeExprTree(Instruction *I, in LinearizeExprTree()
401 SmallVector<std::pair<Instruction *, uint64_t>, 8> Worklist; // (Op, Weight) in LinearizeExprTree()
489 assert((!isa<Instruction>(Op) || in LinearizeExprTree()
490 cast<Instruction>(Op)->getOpcode() != Opcode in LinearizeExprTree()
492 !hasFPAssociativeFlags(cast<Instruction>(Op)))) && in LinearizeExprTree()
501 Instruction *Neg; in LinearizeExprTree()
502 if (((Opcode == Instruction::Mul && match(Op, m_Neg(m_Value()))) || in LinearizeExprTree()
503 (Opcode == Instruction::FMul && match(Op, m_FNeg(m_Value())))) && in LinearizeExprTree()
507 Instruction *Mul = LowerNegateToMultiply(Neg); in LinearizeExprTree()
540 if (Opcode == Instruction::Add && Flags.AllKnownNonNegative && Flags.HasNSW) in LinearizeExprTree()
542 else if (Opcode == Instruction::Mul) { in LinearizeExprTree()
701 NewOp = BinaryOperator::Create(Instruction::BinaryOps(Opcode), Poison, in RewriteExprTree()
735 if (ExpressionChangedStart->getOpcode() == Instruction::Add || in RewriteExprTree()
736 (ExpressionChangedStart->getOpcode() == Instruction::Mul && in RewriteExprTree()
776 static Value *NegateValue(Value *V, Instruction *BI, in NegateValue()
781 ? ConstantFoldUnaryOpOperand(Instruction::FNeg, C, DL) in NegateValue()
797 isReassociableOp(V, Instruction::Add, Instruction::FAdd)) { in NegateValue()
801 if (I->getOpcode() == Instruction::Add) { in NegateValue()
830 Instruction *TheNeg = dyn_cast<Instruction>(U); in NegateValue()
844 if (Instruction *InstInput = dyn_cast<Instruction>(V)) { in NegateValue()
863 if (TheNeg->getOpcode() == Instruction::Sub) { in NegateValue()
875 Instruction *NewNeg = in NegateValue()
886 static bool isLoadCombineCandidate(Instruction *Or) { in isLoadCombineCandidate()
887 SmallVector<Instruction *, 8> Worklist; in isLoadCombineCandidate()
888 SmallSet<Instruction *, 8> Visited; in isLoadCombineCandidate()
891 auto *I = dyn_cast<Instruction>(V); in isLoadCombineCandidate()
909 case Instruction::Or: in isLoadCombineCandidate()
916 case Instruction::Shl: in isLoadCombineCandidate()
917 case Instruction::ZExt: in isLoadCombineCandidate()
923 case Instruction::Load: in isLoadCombineCandidate()
936 static bool shouldConvertOrWithNoCommonBitsToAdd(Instruction *Or) { in shouldConvertOrWithNoCommonBitsToAdd()
941 for (auto Op : {Instruction::Add, Instruction::Sub, Instruction::Mul, in shouldConvertOrWithNoCommonBitsToAdd()
942 Instruction::Shl}) in shouldConvertOrWithNoCommonBitsToAdd()
960 static BinaryOperator *convertOrWithNoCommonBitsToAdd(Instruction *Or) { in convertOrWithNoCommonBitsToAdd()
977 static bool ShouldBreakUpSubtract(Instruction *Sub) { in ShouldBreakUpSubtract()
989 if (isReassociableOp(V0, Instruction::Add, Instruction::FAdd) || in ShouldBreakUpSubtract()
990 isReassociableOp(V0, Instruction::Sub, Instruction::FSub)) in ShouldBreakUpSubtract()
993 if (isReassociableOp(V1, Instruction::Add, Instruction::FAdd) || in ShouldBreakUpSubtract()
994 isReassociableOp(V1, Instruction::Sub, Instruction::FSub)) in ShouldBreakUpSubtract()
998 (isReassociableOp(VB, Instruction::Add, Instruction::FAdd) || in ShouldBreakUpSubtract()
999 isReassociableOp(VB, Instruction::Sub, Instruction::FSub))) in ShouldBreakUpSubtract()
1007 static BinaryOperator *BreakUpSubtract(Instruction *Sub, in BreakUpSubtract()
1031 static BinaryOperator *ConvertShiftToMul(Instruction *Shl) { in ConvertShiftToMul()
1034 MulCst = ConstantFoldBinaryInstruction(Instruction::Shl, MulCst, SA); in ConvertShiftToMul()
1069 if (Instruction *I1 = dyn_cast<Instruction>(Ops[j].Op)) in FindInOperandList()
1070 if (Instruction *I2 = dyn_cast<Instruction>(X)) in FindInOperandList()
1078 if (Instruction *I1 = dyn_cast<Instruction>(Ops[j].Op)) in FindInOperandList()
1079 if (Instruction *I2 = dyn_cast<Instruction>(X)) in FindInOperandList()
1101 BinaryOperator *BO = isReassociableOp(V, Instruction::Mul, Instruction::FMul); in RemoveFactorFromExpression()
1176 BinaryOperator *BO = isReassociableOp(V, Instruction::Mul, Instruction::FMul); in FindSingleUseMultiplyFactors()
1201 if (Opcode == Instruction::And) // ...&X&~X = 0 in OptimizeAndOrXor()
1204 if (Opcode == Instruction::Or) // ...|X|~X = -1 in OptimizeAndOrXor()
1213 if (Opcode == Instruction::And || Opcode == Instruction::Or) { in OptimizeAndOrXor()
1222 assert(Opcode == Instruction::Xor); in OptimizeAndOrXor()
1248 Instruction *I = BinaryOperator::CreateAnd( in createAndInstr()
1282 if (Instruction *T = dyn_cast<Instruction>(Opnd1->getValue())) in CombineXorOpnd()
1359 if (Instruction *T = dyn_cast<Instruction>(Opnd1->getValue())) in CombineXorOpnd()
1361 if (Instruction *T = dyn_cast<Instruction>(Opnd2->getValue())) in CombineXorOpnd()
1370 Value *ReassociatePass::OptimizeXor(Instruction *I, in OptimizeXor()
1372 if (Value *V = OptimizeAndOrXor(Instruction::Xor, Ops)) in OptimizeXor()
1492 Value *ReassociatePass::OptimizeAdd(Instruction *I, in OptimizeAdd()
1520 Instruction *Mul = CreateMul(TheOp, C, "factor", I->getIterator(), I); in OptimizeAdd()
1591 isReassociableOp(Ops[i].Op, Instruction::Mul, Instruction::FMul); in OptimizeAdd()
1653 Instruction *DummyInst = in OptimizeAdd()
1662 isReassociableOp(Ops[i].Op, Instruction::Mul, Instruction::FMul); in OptimizeAdd()
1691 if (Instruction *VI = dyn_cast<Instruction>(V)) in OptimizeAdd()
1695 Instruction *V2 = CreateMul(V, MaxOccVal, "reass.mul", I->getIterator(), I); in OptimizeAdd()
1827 if (Instruction *MI = dyn_cast<Instruction>(M)) in buildMinimalMultiplyDAG()
1932 case Instruction::And: in OptimizeExpression()
1933 case Instruction::Or: in OptimizeExpression()
1938 case Instruction::Xor: in OptimizeExpression()
1943 case Instruction::Add: in OptimizeExpression()
1944 case Instruction::FAdd: in OptimizeExpression()
1949 case Instruction::Mul: in OptimizeExpression()
1950 case Instruction::FMul: in OptimizeExpression()
1963 void ReassociatePass::RecursivelyEraseDeadInsts(Instruction *I, in RecursivelyEraseDeadInsts()
1973 if (Instruction *OpInst = dyn_cast<Instruction>(Op)) in RecursivelyEraseDeadInsts()
1979 void ReassociatePass::EraseInst(Instruction *I) { in EraseInst()
1990 SmallPtrSet<Instruction *, 8> Visited; // Detect self-referential nodes. in EraseInst()
1992 if (Instruction *Op = dyn_cast<Instruction>(V)) { in EraseInst()
2016 SmallVectorImpl<Instruction *> &Candidates) { in getNegatibleInsts()
2019 Instruction *I; in getNegatibleInsts()
2027 case Instruction::FMul: in getNegatibleInsts()
2039 case Instruction::FDiv: in getNegatibleInsts()
2061 Instruction *ReassociatePass::canonicalizeNegFPConstantsForOp(Instruction *I, in canonicalizeNegFPConstantsForOp()
2062 Instruction *Op, in canonicalizeNegFPConstantsForOp()
2064 assert((I->getOpcode() == Instruction::FAdd || in canonicalizeNegFPConstantsForOp()
2065 I->getOpcode() == Instruction::FSub) && "Expected fadd/fsub"); in canonicalizeNegFPConstantsForOp()
2069 SmallVector<Instruction *, 4> Candidates; in canonicalizeNegFPConstantsForOp()
2077 bool IsFSub = I->getOpcode() == Instruction::FSub; in canonicalizeNegFPConstantsForOp()
2082 for (Instruction *Negatible : Candidates) { in canonicalizeNegFPConstantsForOp()
2113 return dyn_cast<Instruction>(NewInst); in canonicalizeNegFPConstantsForOp()
2124 Instruction *ReassociatePass::canonicalizeNegFPConstants(Instruction *I) { in canonicalizeNegFPConstants()
2127 Instruction *Op; in canonicalizeNegFPConstants()
2129 if (Instruction *R = canonicalizeNegFPConstantsForOp(I, Op, X)) in canonicalizeNegFPConstants()
2132 if (Instruction *R = canonicalizeNegFPConstantsForOp(I, Op, X)) in canonicalizeNegFPConstants()
2135 if (Instruction *R = canonicalizeNegFPConstantsForOp(I, Op, X)) in canonicalizeNegFPConstants()
2142 void ReassociatePass::OptimizeInst(Instruction *I) { in OptimizeInst()
2147 if (I->getOpcode() == Instruction::Shl && isa<ConstantInt>(I->getOperand(1))) in OptimizeInst()
2150 if (isReassociableOp(I->getOperand(0), Instruction::Mul) || in OptimizeInst()
2152 (isReassociableOp(I->user_back(), Instruction::Mul) || in OptimizeInst()
2153 isReassociableOp(I->user_back(), Instruction::Add)))) { in OptimizeInst()
2154 Instruction *NI = ConvertShiftToMul(I); in OptimizeInst()
2167 if (Instruction *Res = canonicalizeNegFPConstants(I)) in OptimizeInst()
2186 if (I->getOpcode() == Instruction::Or && in OptimizeInst()
2192 Instruction *NI = convertOrWithNoCommonBitsToAdd(I); in OptimizeInst()
2200 if (I->getOpcode() == Instruction::Sub) { in OptimizeInst()
2202 Instruction *NI = BreakUpSubtract(I, RedoInsts); in OptimizeInst()
2209 if (isReassociableOp(I->getOperand(1), Instruction::Mul) && in OptimizeInst()
2211 !isReassociableOp(I->user_back(), Instruction::Mul))) { in OptimizeInst()
2212 Instruction *NI = LowerNegateToMultiply(I); in OptimizeInst()
2224 } else if (I->getOpcode() == Instruction::FNeg || in OptimizeInst()
2225 I->getOpcode() == Instruction::FSub) { in OptimizeInst()
2227 Instruction *NI = BreakUpSubtract(I, RedoInsts); in OptimizeInst()
2236 if (isReassociableOp(Op, Instruction::FMul) && in OptimizeInst()
2238 !isReassociableOp(I->user_back(), Instruction::FMul))) { in OptimizeInst()
2241 Instruction *NI = LowerNegateToMultiply(I); in OptimizeInst()
2272 if (BO->hasOneUse() && BO->getOpcode() == Instruction::Add && in OptimizeInst()
2273 cast<Instruction>(BO->user_back())->getOpcode() == Instruction::Sub) in OptimizeInst()
2275 if (BO->hasOneUse() && BO->getOpcode() == Instruction::FAdd && in OptimizeInst()
2276 cast<Instruction>(BO->user_back())->getOpcode() == Instruction::FSub) in OptimizeInst()
2313 if (Instruction *VI = dyn_cast<Instruction>(V)) in ReassociateExpression()
2326 if (I->getOpcode() == Instruction::Mul && in ReassociateExpression()
2327 cast<Instruction>(I->user_back())->getOpcode() == Instruction::Add && in ReassociateExpression()
2332 } else if (I->getOpcode() == Instruction::FMul && in ReassociateExpression()
2333 cast<Instruction>(I->user_back())->getOpcode() == in ReassociateExpression()
2334 Instruction::FAdd && in ReassociateExpression()
2352 if (Instruction *OI = dyn_cast<Instruction>(Ops[0].Op)) in ReassociateExpression()
2368 unsigned Idx = I->getOpcode() - Instruction::BinaryOpsBegin; in ReassociateExpression()
2386 const auto *CurrLeafInstr = dyn_cast<Instruction>(Val); in ReassociateExpression()
2487 for (Instruction &I : *BI) { in BuildPairMap()
2502 Instruction *OpI = dyn_cast<Instruction>(Op); in BuildPairMap()
2518 unsigned BinaryIdx = I.getOpcode() - Instruction::BinaryOpsBegin; in BuildPairMap()
2588 Instruction *I = ToRedo.pop_back_val(); in run()
2598 Instruction *I = RedoInsts.front(); in run()