Lines Matching refs:UseInst
78 Value *foldIVUser(Instruction *UseInst, Instruction *IVOperand);
80 bool eliminateIdentitySCEV(Instruction *UseInst, Instruction *IVOperand);
81 bool replaceIVUserWithLoopInvariant(Instruction *UseInst);
85 bool eliminateIVUser(Instruction *UseInst, Instruction *IVOperand);
107 Value *SimplifyIndvar::foldIVUser(Instruction *UseInst, Instruction *IVOperand) { in foldIVUser() argument
112 switch (UseInst->getOpcode()) { in foldIVUser()
119 if (IVOperand != UseInst->getOperand(OperIdx) || in foldIVUser()
120 !isa<ConstantInt>(UseInst->getOperand(1))) in foldIVUser()
133 ConstantInt *D = cast<ConstantInt>(UseInst->getOperand(1)); in foldIVUser()
134 if (UseInst->getOpcode() == Instruction::LShr) { in foldIVUser()
136 uint32_t BitWidth = cast<IntegerType>(UseInst->getType())->getBitWidth(); in foldIVUser()
140 D = ConstantInt::get(UseInst->getContext(), in foldIVUser()
146 if (UseInst->isExact() && in foldIVUser()
151 if (!SE->isSCEVable(UseInst->getType())) in foldIVUser()
155 if (SE->getSCEV(UseInst) != FoldedExpr) in foldIVUser()
159 << " -> " << *UseInst << '\n'); in foldIVUser()
161 UseInst->setOperand(OperIdx, IVSrc); in foldIVUser()
162 assert(SE->getSCEV(UseInst) == FoldedExpr && "bad SCEV with folded oper"); in foldIVUser()
165 UseInst->dropPoisonGeneratingFlags(); in foldIVUser()
622 bool SimplifyIndvar::eliminateIVUser(Instruction *UseInst, in eliminateIVUser() argument
624 if (ICmpInst *ICmp = dyn_cast<ICmpInst>(UseInst)) { in eliminateIVUser()
628 if (BinaryOperator *Bin = dyn_cast<BinaryOperator>(UseInst)) { in eliminateIVUser()
639 if (auto *CI = dyn_cast<CallInst>(UseInst)) in eliminateIVUser()
643 if (auto *TI = dyn_cast<TruncInst>(UseInst)) in eliminateIVUser()
647 if (eliminateIdentitySCEV(UseInst, IVOperand)) in eliminateIVUser()
688 bool SimplifyIndvar::eliminateIdentitySCEV(Instruction *UseInst, in eliminateIdentitySCEV() argument
690 if (!SE->isSCEVable(UseInst->getType()) || in eliminateIdentitySCEV()
691 (UseInst->getType() != IVOperand->getType()) || in eliminateIdentitySCEV()
692 (SE->getSCEV(UseInst) != SE->getSCEV(IVOperand))) in eliminateIdentitySCEV()
711 if (isa<PHINode>(UseInst)) in eliminateIdentitySCEV()
714 if (!DT || !DT->dominates(IVOperand, UseInst)) in eliminateIdentitySCEV()
717 if (!LI->replacementPreservesLCSSAForm(UseInst, IVOperand)) in eliminateIdentitySCEV()
720 LLVM_DEBUG(dbgs() << "INDVARS: Eliminated identity: " << *UseInst << '\n'); in eliminateIdentitySCEV()
722 UseInst->replaceAllUsesWith(IVOperand); in eliminateIdentitySCEV()
725 DeadInsts.emplace_back(UseInst); in eliminateIdentitySCEV()
900 Instruction *UseInst = UseOper.first; in simplifyUsers() local
906 if (isInstructionTriviallyDead(UseInst, /* TLI */ nullptr)) { in simplifyUsers()
907 DeadInsts.emplace_back(UseInst); in simplifyUsers()
912 if (UseInst == CurrIV) continue; in simplifyUsers()
916 if (replaceIVUserWithLoopInvariant(UseInst)) in simplifyUsers()
923 Value *NewOper = foldIVUser(UseInst, IVOperand); in simplifyUsers()
931 if (eliminateIVUser(UseInst, IVOperand)) { in simplifyUsers()
936 if (BinaryOperator *BO = dyn_cast<BinaryOperator>(UseInst)) { in simplifyUsers()
946 CastInst *Cast = dyn_cast<CastInst>(UseInst); in simplifyUsers()
951 if (isSimpleIVUser(UseInst, L, SE)) { in simplifyUsers()
952 pushIVUsers(UseInst, L, Simplified, SimpleIVUsers); in simplifyUsers()