Lines Matching refs:UseInst

80     Value *foldIVUser(Instruction *UseInst, Instruction *IVOperand);
82 bool eliminateIdentitySCEV(Instruction *UseInst, Instruction *IVOperand);
83 bool replaceIVUserWithLoopInvariant(Instruction *UseInst);
84 bool replaceFloatIVWithIntegerIV(Instruction *UseInst);
89 bool eliminateIVUser(Instruction *UseInst, Instruction *IVOperand);
126 Value *SimplifyIndvar::foldIVUser(Instruction *UseInst, Instruction *IVOperand) { in foldIVUser() argument
131 switch (UseInst->getOpcode()) { in foldIVUser()
138 if (IVOperand != UseInst->getOperand(OperIdx) || in foldIVUser()
139 !isa<ConstantInt>(UseInst->getOperand(1))) in foldIVUser()
152 ConstantInt *D = cast<ConstantInt>(UseInst->getOperand(1)); in foldIVUser()
153 if (UseInst->getOpcode() == Instruction::LShr) { in foldIVUser()
155 uint32_t BitWidth = cast<IntegerType>(UseInst->getType())->getBitWidth(); in foldIVUser()
159 D = ConstantInt::get(UseInst->getContext(), in foldIVUser()
167 if (UseInst->isExact() && LHS != SE->getMulExpr(FoldedExpr, RHS)) in foldIVUser()
171 if (!SE->isSCEVable(UseInst->getType())) in foldIVUser()
175 if (SE->getSCEV(UseInst) != FoldedExpr) in foldIVUser()
179 << " -> " << *UseInst << '\n'); in foldIVUser()
181 UseInst->setOperand(OperIdx, IVSrc); in foldIVUser()
182 assert(SE->getSCEV(UseInst) == FoldedExpr && "bad SCEV with folded oper"); in foldIVUser()
185 UseInst->dropPoisonGeneratingFlags(); in foldIVUser()
580 bool SimplifyIndvar::eliminateIVUser(Instruction *UseInst, in eliminateIVUser() argument
582 if (ICmpInst *ICmp = dyn_cast<ICmpInst>(UseInst)) { in eliminateIVUser()
586 if (BinaryOperator *Bin = dyn_cast<BinaryOperator>(UseInst)) { in eliminateIVUser()
597 if (auto *WO = dyn_cast<WithOverflowInst>(UseInst)) in eliminateIVUser()
601 if (auto *SI = dyn_cast<SaturatingInst>(UseInst)) in eliminateIVUser()
605 if (auto *TI = dyn_cast<TruncInst>(UseInst)) in eliminateIVUser()
609 if (eliminateIdentitySCEV(UseInst, IVOperand)) in eliminateIVUser()
657 bool SimplifyIndvar::replaceFloatIVWithIntegerIV(Instruction *UseInst) { in replaceFloatIVWithIntegerIV() argument
658 if (UseInst->getOpcode() != CastInst::SIToFP && in replaceFloatIVWithIntegerIV()
659 UseInst->getOpcode() != CastInst::UIToFP) in replaceFloatIVWithIntegerIV()
662 Instruction *IVOperand = cast<Instruction>(UseInst->getOperand(0)); in replaceFloatIVWithIntegerIV()
666 if (UseInst->getOpcode() == CastInst::SIToFP) in replaceFloatIVWithIntegerIV()
670 int DestNumSigBits = UseInst->getType()->getFPMantissaWidth(); in replaceFloatIVWithIntegerIV()
672 for (User *U : UseInst->users()) { in replaceFloatIVWithIntegerIV()
692 UseInst->getOpcode() == CastInst::UIToFP) { in replaceFloatIVWithIntegerIV()
714 bool SimplifyIndvar::eliminateIdentitySCEV(Instruction *UseInst, in eliminateIdentitySCEV() argument
716 if (!SE->isSCEVable(UseInst->getType()) || in eliminateIdentitySCEV()
717 UseInst->getType() != IVOperand->getType()) in eliminateIdentitySCEV()
720 const SCEV *UseSCEV = SE->getSCEV(UseInst); in eliminateIdentitySCEV()
740 if (isa<PHINode>(UseInst)) in eliminateIdentitySCEV()
743 if (!DT || !DT->dominates(IVOperand, UseInst)) in eliminateIdentitySCEV()
746 if (!LI->replacementPreservesLCSSAForm(UseInst, IVOperand)) in eliminateIdentitySCEV()
750 if (!impliesPoison(IVOperand, UseInst)) { in eliminateIdentitySCEV()
759 LLVM_DEBUG(dbgs() << "INDVARS: Eliminated identity: " << *UseInst << '\n'); in eliminateIdentitySCEV()
761 SE->forgetValue(UseInst); in eliminateIdentitySCEV()
762 UseInst->replaceAllUsesWith(IVOperand); in eliminateIdentitySCEV()
765 DeadInsts.emplace_back(UseInst); in eliminateIdentitySCEV()
906 Instruction *UseInst = UseOper.first; in simplifyUsers() local
912 if (isInstructionTriviallyDead(UseInst, /* TLI */ nullptr)) { in simplifyUsers()
913 DeadInsts.emplace_back(UseInst); in simplifyUsers()
918 if (UseInst == CurrIV) continue; in simplifyUsers()
922 if (replaceIVUserWithLoopInvariant(UseInst)) in simplifyUsers()
927 if ((isa<PtrToIntInst>(UseInst)) || (isa<TruncInst>(UseInst))) in simplifyUsers()
928 for (Use &U : UseInst->uses()) { in simplifyUsers()
939 Value *NewOper = foldIVUser(UseInst, IVOperand); in simplifyUsers()
947 if (eliminateIVUser(UseInst, IVOperand)) { in simplifyUsers()
952 if (BinaryOperator *BO = dyn_cast<BinaryOperator>(UseInst)) { in simplifyUsers()
961 if (replaceFloatIVWithIntegerIV(UseInst)) { in simplifyUsers()
967 CastInst *Cast = dyn_cast<CastInst>(UseInst); in simplifyUsers()
972 if (isSimpleIVUser(UseInst, L, SE)) { in simplifyUsers()
973 pushIVUsers(UseInst, L, Simplified, SimpleIVUsers); in simplifyUsers()