Lines Matching refs:UseInst

78     Value *foldIVUser(Instruction *UseInst, Instruction *IVOperand);
80 bool eliminateIdentitySCEV(Instruction *UseInst, Instruction *IVOperand);
81 bool replaceIVUserWithLoopInvariant(Instruction *UseInst);
86 bool eliminateIVUser(Instruction *UseInst, Instruction *IVOperand);
103 /// IVOperand is guaranteed SCEVable, but UseInst may not be.
108 Value *SimplifyIndvar::foldIVUser(Instruction *UseInst, Instruction *IVOperand) {
113 switch (UseInst->getOpcode()) {
120 if (IVOperand != UseInst->getOperand(OperIdx) ||
121 !isa<ConstantInt>(UseInst->getOperand(1)))
134 ConstantInt *D = cast<ConstantInt>(UseInst->getOperand(1));
135 if (UseInst->getOpcode() == Instruction::LShr) {
137 uint32_t BitWidth = cast<IntegerType>(UseInst->getType())->getBitWidth();
141 D = ConstantInt::get(UseInst->getContext(),
147 if (UseInst->isExact() &&
152 if (!SE->isSCEVable(UseInst->getType()))
156 if (SE->getSCEV(UseInst) != FoldedExpr)
160 << " -> " << *UseInst << '\n');
162 UseInst->setOperand(OperIdx, IVSrc);
163 assert(SE->getSCEV(UseInst) == FoldedExpr && "bad SCEV with folded oper");
166 UseInst->dropPoisonGeneratingFlags();
615 /// but UseInst may not be.
616 bool SimplifyIndvar::eliminateIVUser(Instruction *UseInst,
618 if (ICmpInst *ICmp = dyn_cast<ICmpInst>(UseInst)) {
622 if (BinaryOperator *Bin = dyn_cast<BinaryOperator>(UseInst)) {
633 if (auto *WO = dyn_cast<WithOverflowInst>(UseInst))
637 if (auto *SI = dyn_cast<SaturatingInst>(UseInst))
641 if (auto *TI = dyn_cast<TruncInst>(UseInst))
645 if (eliminateIdentitySCEV(UseInst, IVOperand))
658 /// Replace the UseInst with a constant if possible.
686 bool SimplifyIndvar::eliminateIdentitySCEV(Instruction *UseInst,
688 if (!SE->isSCEVable(UseInst->getType()) ||
689 (UseInst->getType() != IVOperand->getType()) ||
690 (SE->getSCEV(UseInst) != SE->getSCEV(IVOperand)))
709 if (isa<PHINode>(UseInst))
710 // If UseInst is not a PHI node then we know that IVOperand dominates
711 // UseInst directly from the legality of SSA.
712 if (!DT || !DT->dominates(IVOperand, UseInst))
715 if (!LI->replacementPreservesLCSSAForm(UseInst, IVOperand))
718 LLVM_DEBUG(dbgs() << "INDVARS: Eliminated identity: " << *UseInst << '\n');
720 UseInst->replaceAllUsesWith(IVOperand);
723 DeadInsts.emplace_back(UseInst);
870 Instruction *UseInst = UseOper.first;
876 if (isInstructionTriviallyDead(UseInst, /* TLI */ nullptr)) {
877 DeadInsts.emplace_back(UseInst);
882 if (UseInst == CurrIV) continue;
884 // Try to replace UseInst with a loop invariant before any other
886 if (replaceIVUserWithLoopInvariant(UseInst))
893 Value *NewOper = foldIVUser(UseInst, IVOperand);
901 if (eliminateIVUser(UseInst, IVOperand)) {
906 if (BinaryOperator *BO = dyn_cast<BinaryOperator>(UseInst)) {
916 CastInst *Cast = dyn_cast<CastInst>(UseInst);
921 if (isSimpleIVUser(UseInst, L, SE)) {
922 pushIVUsers(UseInst, L, Simplified, SimpleIVUsers);