Lines Matching refs:UseInst
78 Value *foldIVUser(Instruction *UseInst, Instruction *IVOperand);
80 bool eliminateIdentitySCEV(Instruction *UseInst, Instruction *IVOperand);
81 bool replaceIVUserWithLoopInvariant(Instruction *UseInst);
82 bool replaceFloatIVWithIntegerIV(Instruction *UseInst);
87 bool eliminateIVUser(Instruction *UseInst, Instruction *IVOperand);
128 Value *SimplifyIndvar::foldIVUser(Instruction *UseInst, Instruction *IVOperand) { in foldIVUser() argument
133 switch (UseInst->getOpcode()) { in foldIVUser()
140 if (IVOperand != UseInst->getOperand(OperIdx) || in foldIVUser()
141 !isa<ConstantInt>(UseInst->getOperand(1))) in foldIVUser()
154 ConstantInt *D = cast<ConstantInt>(UseInst->getOperand(1)); in foldIVUser()
155 if (UseInst->getOpcode() == Instruction::LShr) { in foldIVUser()
157 uint32_t BitWidth = cast<IntegerType>(UseInst->getType())->getBitWidth(); in foldIVUser()
161 D = ConstantInt::get(UseInst->getContext(), in foldIVUser()
169 if (UseInst->isExact() && LHS != SE->getMulExpr(FoldedExpr, RHS)) in foldIVUser()
173 if (!SE->isSCEVable(UseInst->getType())) in foldIVUser()
177 if (SE->getSCEV(UseInst) != FoldedExpr) in foldIVUser()
181 << " -> " << *UseInst << '\n'); in foldIVUser()
183 UseInst->setOperand(OperIdx, IVSrc); in foldIVUser()
184 assert(SE->getSCEV(UseInst) == FoldedExpr && "bad SCEV with folded oper"); in foldIVUser()
187 UseInst->dropPoisonGeneratingFlags(); in foldIVUser()
604 bool SimplifyIndvar::eliminateIVUser(Instruction *UseInst, in eliminateIVUser() argument
606 if (ICmpInst *ICmp = dyn_cast<ICmpInst>(UseInst)) { in eliminateIVUser()
610 if (BinaryOperator *Bin = dyn_cast<BinaryOperator>(UseInst)) { in eliminateIVUser()
621 if (auto *WO = dyn_cast<WithOverflowInst>(UseInst)) in eliminateIVUser()
625 if (auto *SI = dyn_cast<SaturatingInst>(UseInst)) in eliminateIVUser()
629 if (auto *TI = dyn_cast<TruncInst>(UseInst)) in eliminateIVUser()
633 if (eliminateIdentitySCEV(UseInst, IVOperand)) in eliminateIVUser()
681 bool SimplifyIndvar::replaceFloatIVWithIntegerIV(Instruction *UseInst) { in replaceFloatIVWithIntegerIV() argument
682 if (UseInst->getOpcode() != CastInst::SIToFP && in replaceFloatIVWithIntegerIV()
683 UseInst->getOpcode() != CastInst::UIToFP) in replaceFloatIVWithIntegerIV()
686 Value *IVOperand = UseInst->getOperand(0); in replaceFloatIVWithIntegerIV()
690 if (UseInst->getOpcode() == CastInst::SIToFP) in replaceFloatIVWithIntegerIV()
694 unsigned DestNumSigBits = UseInst->getType()->getFPMantissaWidth(); in replaceFloatIVWithIntegerIV()
696 for (User *U : UseInst->users()) { in replaceFloatIVWithIntegerIV()
720 bool SimplifyIndvar::eliminateIdentitySCEV(Instruction *UseInst, in eliminateIdentitySCEV() argument
722 if (!SE->isSCEVable(UseInst->getType()) || in eliminateIdentitySCEV()
723 (UseInst->getType() != IVOperand->getType()) || in eliminateIdentitySCEV()
724 (SE->getSCEV(UseInst) != SE->getSCEV(IVOperand))) in eliminateIdentitySCEV()
743 if (isa<PHINode>(UseInst)) in eliminateIdentitySCEV()
746 if (!DT || !DT->dominates(IVOperand, UseInst)) in eliminateIdentitySCEV()
749 if (!LI->replacementPreservesLCSSAForm(UseInst, IVOperand)) in eliminateIdentitySCEV()
752 LLVM_DEBUG(dbgs() << "INDVARS: Eliminated identity: " << *UseInst << '\n'); in eliminateIdentitySCEV()
754 UseInst->replaceAllUsesWith(IVOperand); in eliminateIdentitySCEV()
757 DeadInsts.emplace_back(UseInst); in eliminateIdentitySCEV()
893 Instruction *UseInst = UseOper.first; in simplifyUsers() local
899 if (isInstructionTriviallyDead(UseInst, /* TLI */ nullptr)) { in simplifyUsers()
900 DeadInsts.emplace_back(UseInst); in simplifyUsers()
905 if (UseInst == CurrIV) continue; in simplifyUsers()
909 if (replaceIVUserWithLoopInvariant(UseInst)) in simplifyUsers()
917 Value *NewOper = foldIVUser(UseInst, IVOperand); in simplifyUsers()
925 if (eliminateIVUser(UseInst, IVOperand)) { in simplifyUsers()
930 if (BinaryOperator *BO = dyn_cast<BinaryOperator>(UseInst)) { in simplifyUsers()
941 if (replaceFloatIVWithIntegerIV(UseInst)) { in simplifyUsers()
947 CastInst *Cast = dyn_cast<CastInst>(UseInst); in simplifyUsers()
952 if (isSimpleIVUser(UseInst, L, SE)) { in simplifyUsers()
953 pushIVUsers(UseInst, L, Simplified, SimpleIVUsers); in simplifyUsers()