Lines Matching refs:UseInst
88 Value *foldIVUser(Instruction *UseInst, Instruction *IVOperand);
90 bool eliminateIdentitySCEV(Instruction *UseInst, Instruction *IVOperand);
91 bool replaceIVUserWithLoopInvariant(Instruction *UseInst);
92 bool replaceFloatIVWithIntegerIV(Instruction *UseInst);
97 bool eliminateIVUser(Instruction *UseInst, Instruction *IVOperand);
134 Value *SimplifyIndvar::foldIVUser(Instruction *UseInst, Instruction *IVOperand) { in foldIVUser() argument
139 switch (UseInst->getOpcode()) { in foldIVUser()
146 if (IVOperand != UseInst->getOperand(OperIdx) || in foldIVUser()
147 !isa<ConstantInt>(UseInst->getOperand(1))) in foldIVUser()
160 ConstantInt *D = cast<ConstantInt>(UseInst->getOperand(1)); in foldIVUser()
161 if (UseInst->getOpcode() == Instruction::LShr) { in foldIVUser()
163 uint32_t BitWidth = cast<IntegerType>(UseInst->getType())->getBitWidth(); in foldIVUser()
167 D = ConstantInt::get(UseInst->getContext(), in foldIVUser()
175 if (UseInst->isExact() && LHS != SE->getMulExpr(FoldedExpr, RHS)) in foldIVUser()
179 if (!SE->isSCEVable(UseInst->getType())) in foldIVUser()
183 if (SE->getSCEV(UseInst) != FoldedExpr) in foldIVUser()
187 << " -> " << *UseInst << '\n'); in foldIVUser()
189 UseInst->setOperand(OperIdx, IVSrc); in foldIVUser()
190 assert(SE->getSCEV(UseInst) == FoldedExpr && "bad SCEV with folded oper"); in foldIVUser()
193 UseInst->dropPoisonGeneratingFlags(); in foldIVUser()
594 bool SimplifyIndvar::eliminateIVUser(Instruction *UseInst, in eliminateIVUser() argument
596 if (ICmpInst *ICmp = dyn_cast<ICmpInst>(UseInst)) { in eliminateIVUser()
600 if (BinaryOperator *Bin = dyn_cast<BinaryOperator>(UseInst)) { in eliminateIVUser()
611 if (auto *WO = dyn_cast<WithOverflowInst>(UseInst)) in eliminateIVUser()
615 if (auto *SI = dyn_cast<SaturatingInst>(UseInst)) in eliminateIVUser()
619 if (auto *TI = dyn_cast<TruncInst>(UseInst)) in eliminateIVUser()
623 if (eliminateIdentitySCEV(UseInst, IVOperand)) in eliminateIVUser()
682 bool SimplifyIndvar::replaceFloatIVWithIntegerIV(Instruction *UseInst) { in replaceFloatIVWithIntegerIV() argument
683 if (UseInst->getOpcode() != CastInst::SIToFP && in replaceFloatIVWithIntegerIV()
684 UseInst->getOpcode() != CastInst::UIToFP) in replaceFloatIVWithIntegerIV()
687 Instruction *IVOperand = cast<Instruction>(UseInst->getOperand(0)); in replaceFloatIVWithIntegerIV()
691 if (UseInst->getOpcode() == CastInst::SIToFP) in replaceFloatIVWithIntegerIV()
695 int DestNumSigBits = UseInst->getType()->getFPMantissaWidth(); in replaceFloatIVWithIntegerIV()
697 for (User *U : UseInst->users()) { in replaceFloatIVWithIntegerIV()
717 UseInst->getOpcode() == CastInst::UIToFP) { in replaceFloatIVWithIntegerIV()
739 bool SimplifyIndvar::eliminateIdentitySCEV(Instruction *UseInst, in eliminateIdentitySCEV() argument
741 if (!SE->isSCEVable(UseInst->getType()) || in eliminateIdentitySCEV()
742 UseInst->getType() != IVOperand->getType()) in eliminateIdentitySCEV()
745 const SCEV *UseSCEV = SE->getSCEV(UseInst); in eliminateIdentitySCEV()
765 if (isa<PHINode>(UseInst)) in eliminateIdentitySCEV()
768 if (!DT || !DT->dominates(IVOperand, UseInst)) in eliminateIdentitySCEV()
771 if (!LI->replacementPreservesLCSSAForm(UseInst, IVOperand)) in eliminateIdentitySCEV()
775 if (!impliesPoison(IVOperand, UseInst)) { in eliminateIdentitySCEV()
784 LLVM_DEBUG(dbgs() << "INDVARS: Eliminated identity: " << *UseInst << '\n'); in eliminateIdentitySCEV()
786 SE->forgetValue(UseInst); in eliminateIdentitySCEV()
787 UseInst->replaceAllUsesWith(IVOperand); in eliminateIdentitySCEV()
790 DeadInsts.emplace_back(UseInst); in eliminateIdentitySCEV()
929 Instruction *UseInst = UseOper.first; in simplifyUsers() local
935 if (isInstructionTriviallyDead(UseInst, /* TLI */ nullptr)) { in simplifyUsers()
936 DeadInsts.emplace_back(UseInst); in simplifyUsers()
941 if (UseInst == CurrIV) continue; in simplifyUsers()
945 if (replaceIVUserWithLoopInvariant(UseInst)) in simplifyUsers()
950 if ((isa<PtrToIntInst>(UseInst)) || (isa<TruncInst>(UseInst))) in simplifyUsers()
951 for (Use &U : UseInst->uses()) { in simplifyUsers()
962 Value *NewOper = foldIVUser(UseInst, IVOperand); in simplifyUsers()
970 if (eliminateIVUser(UseInst, IVOperand)) { in simplifyUsers()
975 if (BinaryOperator *BO = dyn_cast<BinaryOperator>(UseInst)) { in simplifyUsers()
984 if (replaceFloatIVWithIntegerIV(UseInst)) { in simplifyUsers()
990 CastInst *Cast = dyn_cast<CastInst>(UseInst); in simplifyUsers()
995 if (isSimpleIVUser(UseInst, L, SE)) { in simplifyUsers()
996 pushIVUsers(UseInst, Simplified, SimpleIVUsers); in simplifyUsers()