83#define DEBUG_TYPE "indvars"
86STATISTIC(NumReplaced ,
"Number of exit values replaced");
87STATISTIC(NumLFTR ,
"Number of loop exit tests replaced");
88STATISTIC(NumElimExt ,
"Number of IV sign/zero extends eliminated");
89STATISTIC(NumElimIV ,
"Number of congruent IVs eliminated");
94 const ScalarOptions &Opts;
101 std::unique_ptr<MemorySSAUpdater> MSSAU;
106 bool RunUnswitching =
false;
109 bool rewriteNonIntegerIVs(
Loop *L);
115 bool canonicalizeExitCondition(
Loop *L);
122 bool rewriteFirstIterationLoopExitValues(
Loop *L);
125 const SCEV *ExitCount,
128 bool sinkUnusedInvariants(
Loop *L);
136 WidenIndVars(WidenIndVars) {
138 MSSAU = std::make_unique<MemorySSAUpdater>(MSSA);
143 bool runUnswitching()
const {
return RunUnswitching; }
154 bool isExact =
false;
230static std::optional<FloatingPointIV>
232 assert(L->getLoopLatch() &&
"Must be in simplified form.");
236 unsigned BackEdge = IncomingEdge ^ 1;
246 if (!Incr || Incr->getOpcode() != Instruction::FAdd)
252 if (!IncValueVal || Incr->getOperand(0) != PN)
258 if (!Incr->hasNUses(2))
264 [](
const User *U) { return isa<FCmpInst>(U); });
265 if (It == Incr->users().end())
269 if (!Compare->hasOneUse())
281 if (!L->contains(ExitingBB) ||
282 (L->contains(BI->getSuccessor(0)) && L->contains(BI->getSuccessor(1))))
287 if (!DT.
dominates(ExitingBB, L->getLoopLatch()))
290 bool ExitsOnTrue = !L->contains(BI->getSuccessor(0));
298 IncValueVal->getValueAPF(),
299 ExitValueVal->getValueAPF(), Compare, ExitsOnTrue);
306static std::optional<IntegerIV>
314 int64_t InitValue, IncrValue, ExitValue;
343 int64_t Start = InitValue, Step = IncrValue, Bound = ExitValue;
358 switch (ContinuePred) {
367 if (Dist % Step != 0)
372 Last = Start + Step == Bound ? Bound + Step : Start + Step;
382 return IntegerIV{InitValue, IncrValue, ExitValue, NewPred};
390 std::unique_ptr<MemorySSAUpdater> &MSSAU) {
392 unsigned BackEdge = IncomingEdge ^ 1;
398 LLVM_DEBUG(
dbgs() <<
"INDVARS: Rewriting floating-point IV to integer IV:\n"
404 <<
" Original PN: " << *PN <<
"\n");
415 Incr->getName() +
".int", Incr->getIterator());
420 BI->getIterator(), IIV.
NewPred, NewAdd,
461bool IndVarSimplify::handleFloatingPointIV(
Loop *L,
PHINode *PN) {
477bool IndVarSimplify::rewriteNonIntegerIVs(
Loop *L) {
486 for (WeakTrackingVH &
PHI : PHIs)
488 Changed |= handleFloatingPointIV(L, PN);
507bool IndVarSimplify::rewriteFirstIterationLoopExitValues(
Loop *L) {
511 SmallVector<BasicBlock *, 8> ExitBlocks;
512 L->getUniqueExitBlocks(ExitBlocks);
514 bool MadeAnyChanges =
false;
515 for (
auto *ExitBB : ExitBlocks) {
518 for (PHINode &PN : ExitBB->phis()) {
520 IncomingValIdx !=
E; ++IncomingValIdx) {
528 if (!
L->getLoopLatch() ||
529 !DT->
dominates(IncomingBB,
L->getLoopLatch()))
539 Cond = BI->getCondition();
541 Cond =
SI->getCondition();
545 if (!
L->isLoopInvariant(
Cond))
551 if (!ExitVal || ExitVal->getParent() !=
L->getHeader())
557 auto *LoopPreheader =
L->getLoopPreheader();
558 assert(LoopPreheader &&
"Invalid loop");
559 int PreheaderIdx = ExitVal->getBasicBlockIndex(LoopPreheader);
560 if (PreheaderIdx != -1) {
561 assert(ExitVal->getParent() ==
L->getHeader() &&
562 "ExitVal must be in loop header");
563 MadeAnyChanges =
true;
565 ExitVal->getIncomingValue(PreheaderIdx));
571 return MadeAnyChanges;
584 bool IsSigned = Cast->
getOpcode() == Instruction::SExt;
585 if (!IsSigned && Cast->
getOpcode() != Instruction::ZExt)
598 if (NarrowIVWidth >= Width)
608 if (
TTI &&
TTI->getArithmeticInstrCost(Instruction::Add, Ty, CostKind) >
609 TTI->getArithmeticInstrCost(Instruction::Add,
639class IndVarSimplifyVisitor :
public IVVisitor {
641 const TargetTransformInfo *
TTI;
647 IndVarSimplifyVisitor(PHINode *
IV, ScalarEvolution *SCEV,
648 const TargetTransformInfo *
TTI,
649 const DominatorTree *DTree)
656 void visitCast(CastInst *Cast)
override {
visitIVCast(Cast, WI, SE,
TTI); }
666bool IndVarSimplify::simplifyAndExtend(
Loop *L,
672 L->getBlocks()[0]->getModule(), Intrinsic::experimental_guard);
673 bool HasGuards = GuardDecl && !GuardDecl->use_empty();
683 while (!LoopPhis.empty()) {
691 PHINode *CurrIV = LoopPhis.pop_back_val();
694 IndVarSimplifyVisitor Visitor(CurrIV, SE,
TTI, DT);
701 if (Visitor.WI.WidestNativeType) {
704 }
while(!LoopPhis.empty());
714 WideIVs.
back(), LI, SE,
Rewriter, DT, DeadInsts, ElimExt, Widened,
715 HasGuards, Opts.indvars_post_increment_ranges)) {
716 NumElimExt += ElimExt;
717 NumWidened += Widened;
719 LoopPhis.push_back(WidePhi);
739 case Instruction::Add:
740 case Instruction::Sub:
742 case Instruction::GetElementPtr:
752 if (Phi && Phi->getParent() == L->getHeader()) {
757 if (IncI->
getOpcode() == Instruction::GetElementPtr)
762 if (Phi && Phi->getParent() == L->getHeader()) {
785 assert(L->getLoopLatch() &&
"Must be in simplified form");
808 if (!L->isLoopInvariant(
RHS)) {
809 if (!L->isLoopInvariant(
LHS))
822 int Idx = Phi->getBasicBlockIndex(L->getLoopLatch());
827 Value *IncV = Phi->getIncomingValue(Idx);
878 assert(Phi->getParent() == L->getHeader());
879 assert(L->getLoopLatch());
888 int LatchIdx = Phi->getBasicBlockIndex(L->getLoopLatch());
889 Value *IncV = Phi->getIncomingValue(LatchIdx);
910 const SCEV *BestInit =
nullptr;
912 assert(LatchBlock &&
"Must be in simplified form");
926 if (PhiWidth < BCWidth || !
DL.isLegalInteger(PhiWidth))
935 Value *IncPhi = Phi->getIncomingValueForBlock(LatchBlock);
949 if (!Phi->getType()->isIntegerTy() &&
969 else if (PhiWidth <= SE->getTypeSizeInBits(BestPhi->
getType()))
982 const SCEV *ExitCount,
bool UsePostInc,
Loop *L,
1012 "Computed iteration count is not loop invariant!");
1013 return Rewriter.expandCodeFor(IVLimit, ARBase->
getType(),
1022bool IndVarSimplify::
1023linearFunctionTestReplace(
Loop *L, BasicBlock *ExitingBB,
1024 const SCEV *ExitCount,
1025 PHINode *IndVar, SCEVExpander &
Rewriter) {
1026 assert(
L->getLoopLatch() &&
"Loop no longer in simplified form?");
1032 Value *CmpIndVar = IndVar;
1033 bool UsePostInc =
false;
1038 if (ExitingBB ==
L->getLoopLatch()) {
1043 bool SafeToPostInc =
1047 if (SafeToPostInc) {
1060 "genLoopLimit missed a cast");
1076 if (BO->hasNoUnsignedWrap())
1078 if (BO->hasNoSignedWrap())
1084 ICmpInst::Predicate
P;
1086 P = ICmpInst::ICMP_NE;
1088 P = ICmpInst::ICMP_EQ;
1095 Builder.SetCurrentDebugLocation(
Cond->getDebugLoc());
1104 if (CmpIndVarSize > ExitCntSize) {
1114 const SCEV *
IV = SE->
getSCEV(CmpIndVar);
1116 const SCEV *ZExtTrunc =
1119 if (ZExtTrunc ==
IV) {
1121 ExitCnt = Builder.CreateZExt(ExitCnt, IndVar->
getType(),
1124 const SCEV *SExtTrunc =
1126 if (SExtTrunc ==
IV) {
1128 ExitCnt = Builder.CreateSExt(ExitCnt, IndVar->
getType(),
1135 L->makeLoopInvariant(ExitCnt, Discard);
1137 CmpIndVar = Builder.CreateTrunc(CmpIndVar, ExitCnt->
getType(),
1140 LLVM_DEBUG(
dbgs() <<
"INDVARS: Rewriting loop exit condition to:\n"
1141 <<
" LHS:" << *CmpIndVar <<
'\n'
1142 <<
" op:\t" << (
P == ICmpInst::ICMP_NE ?
"!=" :
"==")
1144 <<
" RHS:\t" << *ExitCnt <<
"\n"
1145 <<
"ExitCount:\t" << *ExitCount <<
"\n"
1148 Value *
Cond = Builder.CreateICmp(
P, CmpIndVar, ExitCnt,
"exitcond");
1169bool IndVarSimplify::sinkUnusedInvariants(
Loop *L) {
1171 if (!ExitBlock)
return false;
1174 if (!Preheader)
return false;
1176 bool MadeAnyChanges =
false;
1177 SmallVector<Value *, 16> SunkInsts;
1194 if (
I.mayHaveSideEffects() ||
I.mayReadFromMemory())
1217 bool UsedInLoop =
false;
1218 for (Use &U :
I.uses()) {
1224 UseBB =
P->getIncomingBlock(i);
1226 if (UseBB == Preheader ||
L->contains(UseBB)) {
1239 MadeAnyChanges =
true;
1242 if (!SunkInsts.
empty())
1245 return MadeAnyChanges;
1251 LLVM_DEBUG(
dbgs() <<
"Replacing condition of loop-exiting branch " << *BI
1252 <<
" with " << *NewCond <<
"\n");
1254 if (OldCond->use_empty())
1261 bool ExitIfTrue = !L->contains(*
succ_begin(ExitingBB));
1263 return ConstantInt::get(OldCond->getType(),
1264 IsTaken ? ExitIfTrue : !ExitIfTrue);
1277 assert(L->isLoopSimplifyForm() &&
"Should only do it in simplify form!");
1278 auto *LoopPreheader = L->getLoopPreheader();
1279 auto *LoopHeader = L->getHeader();
1281 for (
auto &PN : LoopHeader->phis()) {
1293 while (!Worklist.
empty()) {
1295 if (!Visited.
insert(
I).second)
1299 if (!L->contains(
I))
1306 I->replaceAllUsesWith(Res);
1317 BasicBlock *Preheader = L->getLoopPreheader();
1318 assert(Preheader &&
"Preheader doesn't exist");
1320 auto *LHSV = Rewriter.expandCodeFor(LIP.
LHS);
1321 auto *RHSV = Rewriter.expandCodeFor(LIP.
RHS);
1322 bool ExitIfTrue = !L->contains(*
succ_begin(ExitingBB));
1327 return Builder.CreateICmp(InvariantPred, LHSV, RHSV,
1331static std::optional<Value *>
1333 const SCEV *MaxIter,
bool Inverted,
bool SkipLastIter,
1351 auto *MaxIterTy = MaxIter->
getType();
1380 return std::nullopt;
1395 "Not a loop exit!");
1408 auto GoThrough = [&](
Value *
V) {
1429 if (!GoThrough(Curr))
1432 }
while (!Worklist.
empty());
1439 if (!SkipLastIter && LeafConditions.
size() > 1 &&
1443 for (
auto *ICmp : LeafConditions) {
1446 const SCEV *ExitMax = EL.SymbolicMaxNotTaken;
1455 if (WideExitMax == WideMaxIter)
1456 ICmpsFailingOnLastIter.
insert(ICmp);
1460 for (
auto *OldCond : LeafConditions) {
1465 bool OptimisticSkipLastIter = SkipLastIter;
1466 if (!OptimisticSkipLastIter) {
1467 if (ICmpsFailingOnLastIter.
size() > 1)
1468 OptimisticSkipLastIter =
true;
1469 else if (ICmpsFailingOnLastIter.
size() == 1)
1470 OptimisticSkipLastIter = !ICmpsFailingOnLastIter.
count(OldCond);
1474 OptimisticSkipLastIter, SE, Rewriter)) {
1476 auto *NewCond = *Replaced;
1478 NCI->setName(OldCond->
getName() +
".first_iter");
1480 LLVM_DEBUG(
dbgs() <<
"Unknown exit count: Replacing " << *OldCond
1481 <<
" with " << *NewCond <<
"\n");
1487 ICmpsFailingOnLastIter.
erase(OldCond);
1493bool IndVarSimplify::canonicalizeExitCondition(
Loop *L) {
1503 SmallVector<BasicBlock*, 16> ExitingBlocks;
1504 L->getExitingBlocks(ExitingBlocks);
1506 for (
auto *ExitingBB : ExitingBlocks) {
1512 if (!ICmp || !ICmp->hasOneUse())
1515 auto *
LHS = ICmp->getOperand(0);
1516 auto *
RHS = ICmp->getOperand(1);
1520 if (!
L->isLoopInvariant(
RHS)) {
1521 if (!
L->isLoopInvariant(
LHS))
1528 Value *LHSOp =
nullptr;
1532 const unsigned InnerBitWidth =
DL.getTypeSizeInBits(LHSOp->
getType());
1533 const unsigned OuterBitWidth =
DL.getTypeSizeInBits(
RHS->
getType());
1534 auto FullCR = ConstantRange::getFull(InnerBitWidth);
1535 FullCR = FullCR.zeroExtend(OuterBitWidth);
1537 if (FullCR.contains(RHSCR)) {
1540 ICmp->setPredicate(ICmp->getUnsignedPredicate());
1550 for (
auto *ExitingBB : ExitingBlocks) {
1556 if (!ICmp || !ICmp->hasOneUse() || !ICmp->isUnsigned())
1559 bool Swapped =
false;
1560 auto *
LHS = ICmp->getOperand(0);
1561 auto *
RHS = ICmp->getOperand(1);
1562 if (
L->isLoopInvariant(
LHS) ==
L->isLoopInvariant(
RHS))
1565 if (
L->isLoopInvariant(
LHS)) {
1576 Value *LHSOp =
nullptr;
1593 auto doRotateTransform = [&]() {
1594 assert(ICmp->isUnsigned() &&
"must have proven unsigned already");
1596 Instruction::Trunc,
RHS, LHSOp->
getType(),
"",
1597 L->getLoopPreheader()->getTerminator()->getIterator());
1601 ICmp->setOperand(Swapped ? 1 : 0, LHSOp);
1602 ICmp->setOperand(Swapped ? 0 : 1, NewRHS);
1604 ICmp->setSameSign(
false);
1609 const unsigned InnerBitWidth =
DL.getTypeSizeInBits(LHSOp->
getType());
1610 const unsigned OuterBitWidth =
DL.getTypeSizeInBits(
RHS->
getType());
1611 auto FullCR = ConstantRange::getFull(InnerBitWidth);
1612 FullCR = FullCR.zeroExtend(OuterBitWidth);
1614 if (FullCR.contains(RHSCR)) {
1615 doRotateTransform();
1627bool IndVarSimplify::optimizeLoopExits(
Loop *L, SCEVExpander &
Rewriter) {
1628 SmallVector<BasicBlock*, 16> ExitingBlocks;
1629 L->getExitingBlocks(ExitingBlocks);
1646 if (!DT->
dominates(ExitingBB,
L->getLoopLatch()))
1661 if (ExitingBlocks.
empty())
1672 llvm::sort(ExitingBlocks, [&](BasicBlock *
A, BasicBlock *
B) {
1675 if (
A ==
B)
return false;
1680 "expected total dominance order!");
1685 for (
unsigned i = 1; i < ExitingBlocks.
size(); i++) {
1691 bool SkipLastIter =
false;
1693 auto UpdateSkipLastIter = [&](
const SCEV *MaxExitCount) {
1697 CurrMaxExit = MaxExitCount;
1702 if (CurrMaxExit == MaxBECount)
1703 SkipLastIter =
true;
1705 SmallPtrSet<const SCEV *, 8> DominatingExactExitCounts;
1706 for (BasicBlock *ExitingBB : ExitingBlocks) {
1707 const SCEV *ExactExitCount = SE->
getExitCount(L, ExitingBB);
1709 L, ExitingBB, ScalarEvolution::ExitCountKind::SymbolicMaximum);
1714 auto OptimizeCond = [&](
bool SkipLastIter) {
1716 MaxBECount, SkipLastIter,
1736 if (OptimizeCond(
false))
1738 else if (SkipLastIter && OptimizeCond(
true))
1740 UpdateSkipLastIter(MaxExitCount);
1744 UpdateSkipLastIter(ExactExitCount);
1751 if (ExactExitCount->
isZero()) {
1752 foldExit(L, ExitingBB,
true, DeadInsts);
1760 "Exit counts must be integers");
1772 foldExit(L, ExitingBB,
false, DeadInsts);
1781 if (!DominatingExactExitCounts.
insert(ExactExitCount).second) {
1782 foldExit(L, ExitingBB,
false, DeadInsts);
1808 if (CB->onlyAccessesInaccessibleMemory())
1815bool IndVarSimplify::predicateLoopExits(
Loop *L, SCEVExpander &
Rewriter) {
1816 SmallVector<BasicBlock*, 16> ExitingBlocks;
1817 L->getExitingBlocks(ExitingBlocks);
1828 if (!Opts.indvars_predicate_loops)
1862 if (!ExitBlock->
phis().empty())
1865 const SCEV *ExitCount = SE->
getExitCount(L, ExitingBB);
1867 !
Rewriter.isSafeToExpand(ExitCount))
1871 "Exit count must be loop invariant");
1879 for (BasicBlock *ExitingBB : ExitingBlocks)
1890 llvm::sort(ExitingBlocks, [&](BasicBlock *
A, BasicBlock *
B) {
1904 for (
unsigned i = 1; i < ExitingBlocks.size(); i++)
1906 "Not sorted by dominance");
1910 for (
unsigned i = 0, e = ExitingBlocks.size(); i < e; i++)
1911 if (BadExit(ExitingBlocks[i])) {
1912 ExitingBlocks.resize(i);
1916 if (ExitingBlocks.empty())
1932 bool HasThreadLocalSideEffects =
false;
1933 for (BasicBlock *BB :
L->blocks())
1934 for (
auto &
I : *BB) {
1936 if (
I.mayHaveSideEffects()) {
1937 if (!Opts.indvars_predicate_loop_traps)
1939 HasThreadLocalSideEffects =
true;
1945 if (!
SI->isSimple())
1954 if (
I.getType()->isTokenTy()) {
1955 for (Instruction *UserInst :
I.users()) {
1956 if (!
L->contains(UserInst))
1973 Rewriter.setInsertPoint(
L->getLoopPreheader()->getTerminator());
1975 Value *ExactBTCV =
nullptr;
1976 for (BasicBlock *ExitingBB : ExitingBlocks) {
1977 const SCEV *ExitCount = SE->
getExitCount(L, ExitingBB);
1980 if (HasThreadLocalSideEffects) {
1982 for (
const BasicBlock *Succ : BI->
successors()) {
1994 if (ExitCount == ExactBTC) {
1996 B.getFalse() :
B.getTrue();
2000 ExactBTCV =
Rewriter.expandCodeFor(ExactBTC);
2004 ECV =
B.CreateZExt(ECV, WiderTy);
2005 RHS =
B.CreateZExt(
RHS, WiderTy);
2008 ICmpInst::ICMP_NE : ICmpInst::ICMP_EQ;
2009 NewCond =
B.CreateICmp(
Pred, ECV,
RHS);
2016 RunUnswitching =
true;
2026bool IndVarSimplify::run(
Loop *L) {
2028 assert(
L->isRecursivelyLCSSAForm(*DT, *LI) &&
2029 "LCSSA required to run indvars!");
2040 if (!
L->isLoopSimplifyForm())
2046 Changed |= rewriteNonIntegerIVs(L);
2049 SCEVExpander
Rewriter(*SE,
"indvars");
2050#if LLVM_ENABLE_ABI_BREAKING_CHECKS
2069 Opts.replexitval, DeadInsts)) {
2076 NumElimIV +=
Rewriter.replaceCongruentIVs(L, DT, DeadInsts,
TTI);
2080 Changed |= canonicalizeExitCondition(L);
2083 if (optimizeLoopExits(L,
Rewriter)) {
2093 if (predicateLoopExits(L,
Rewriter)) {
2101 if (!Opts.disable_lftr) {
2104 SmallVector<BasicBlock*, 16> ExitingBlocks;
2105 L->getExitingBlocks(ExitingBlocks);
2106 for (BasicBlock *ExitingBB : ExitingBlocks) {
2120 const SCEV *ExitCount = SE->
getExitCount(L, ExitingBB);
2141 if (!
Rewriter.isSafeToExpand(ExitCount))
2144 Changed |= linearFunctionTestReplace(L, ExitingBB,
2156 while (!DeadInsts.
empty()) {
2170 Changed |= sinkUnusedInvariants(L);
2175 Changed |= rewriteFirstIterationLoopExitValues(L);
2181 assert(
L->isRecursivelyLCSSAForm(*DT, *LI) &&
2182 "Indvars did not preserve LCSSA!");
2184 MSSAU->getMemorySSA()->verifyMemorySSA();
2192 Function *
F = L.getHeader()->getParent();
2196 IndVarSimplify IVS(Opts, &AR.
LI, &AR.
SE, &AR.
DT,
DL, &AR.
TLI, &AR.
TTI,
2197 AR.
MSSA, WidenIndVars && Opts.indvars_widen_indvars);
2203 if (IVS.runUnswitching()) {
const TargetLowering & TLI
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
AArch64 Predicate As Counter Loop Rewrites
This file declares a class to represent arbitrary precision floating point values and provide a varie...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
static GCRegistry::Add< ErlangGC > A("erlang", "erlang-compatible garbage collector")
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
static GCRegistry::Add< OcamlGC > B("ocaml", "ocaml 3.10-compatible GC")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
This header defines various interfaces for pass management in LLVM.
This defines the Use class.
static bool optimizeLoopExitWithUnknownExitCount(const Loop *L, CondBrInst *BI, BasicBlock *ExitingBB, const SCEV *MaxIter, bool SkipLastIter, ScalarEvolution *SE, SCEVExpander &Rewriter, SmallVectorImpl< WeakTrackingVH > &DeadInsts)
static Value * genLoopLimit(PHINode *IndVar, BasicBlock *ExitingBB, const SCEV *ExitCount, bool UsePostInc, Loop *L, SCEVExpander &Rewriter, ScalarEvolution *SE)
Insert an IR expression which computes the value held by the IV IndVar (which must be an loop counter...
static bool isLoopExitTestBasedOn(Value *V, BasicBlock *ExitingBB)
Whether the current loop exit test is based on this value.
static void visitIVCast(CastInst *Cast, WideIVInfo &WI, ScalarEvolution *SE, const TargetTransformInfo *TTI)
Update information about the induction variable that is extended by this sign or zero extend operatio...
static bool isRepresentableAsExactInteger(const APFloat &FPVal, int64_t IntVal)
Ensure we stay within the bounds of fp values that can be represented as integers without gaps,...
static void replaceLoopPHINodesWithPreheaderValues(LoopInfo *LI, Loop *L, SmallVectorImpl< WeakTrackingVH > &DeadInsts, ScalarEvolution &SE)
static void replaceExitCond(CondBrInst *BI, Value *NewCond, SmallVectorImpl< WeakTrackingVH > &DeadInsts)
static bool needsLFTR(Loop *L, BasicBlock *ExitingBB)
linearFunctionTestReplace policy.
static Value * createInvariantCond(const Loop *L, BasicBlock *ExitingBB, const ScalarEvolution::LoopInvariantPredicate &LIP, SCEVExpander &Rewriter)
static bool isLoopCounter(PHINode *Phi, Loop *L, ScalarEvolution *SE)
Return true if the given phi is a "counter" in L.
static std::optional< Value * > createReplacement(ICmpInst *ICmp, const Loop *L, BasicBlock *ExitingBB, const SCEV *MaxIter, bool Inverted, bool SkipLastIter, ScalarEvolution *SE, SCEVExpander &Rewriter)
static bool hasConcreteDefImpl(Value *V, SmallPtrSetImpl< Value * > &Visited, unsigned Depth)
Recursive helper for hasConcreteDef().
static bool hasConcreteDef(Value *V)
Return true if the given value is concrete.
static void foldExit(const Loop *L, BasicBlock *ExitingBB, bool IsTaken, SmallVectorImpl< WeakTrackingVH > &DeadInsts)
static PHINode * getLoopPhiForCounter(Value *IncV, Loop *L)
Given an Value which is hoped to be part of an add recurance in the given loop, return the associated...
static Constant * createFoldedExitCond(const Loop *L, BasicBlock *ExitingBB, bool IsTaken)
static std::optional< IntegerIV > tryConvertToIntegerIV(const FloatingPointIV &FPIV)
Ensure that the floating-point IV can be converted to a semantics-preserving signed 32-bit integer IV...
static std::optional< FloatingPointIV > maybeFloatingPointRecurrence(Loop *L, PHINode *PN, const DominatorTree &DT)
Analyze a PN to determine whether it represents a simple floating-point induction variable,...
static void canonicalizeToIntegerIV(Loop *L, PHINode *PN, const FloatingPointIV &FPIV, const IntegerIV &IIV, const TargetLibraryInfo *TLI, std::unique_ptr< MemorySSAUpdater > &MSSAU)
Rewrite the floating-point IV as an integer IV.
static PHINode * FindLoopCounter(Loop *L, BasicBlock *ExitingBB, const SCEV *BECount, ScalarEvolution *SE, DominatorTree *DT)
Search the loop header for a loop counter (anadd rec w/step of one) suitable for use by LFTR.
static bool crashingBBWithoutEffect(const BasicBlock &BB)
static CmpInst::Predicate getIntegerPredicate(CmpInst::Predicate FPPred)
static bool ConvertToSInt(const APFloat &APF, int64_t &IntVal)
Convert APF to an integer, if possible.
SmallVector< MachineOperand, 4 > Cond
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
This file defines the SmallPtrSet class.
This file defines the SmallVector class.
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
virt reg Virtual Register Rewriter
static const uint32_t IV[8]
static constexpr roundingMode rmTowardZero
static LLVM_ABI unsigned int semanticsPrecision(const fltSemantics &)
static LLVM_ABI bool isIEEELikeFP(const fltSemantics &)
const fltSemantics & getSemantics() const
opStatus convertToInteger(MutableArrayRef< integerPart > Input, unsigned int Width, bool IsSigned, roundingMode RM, bool *IsExact) const
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
LLVM Basic Block Representation.
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
LLVM_ABI const_iterator getFirstInsertionPt() const
Returns an iterator to the first instruction in this block that is suitable for inserting a non-PHI i...
const Function * getParent() const
Return the enclosing method, or null if none.
InstListType::iterator iterator
Instruction iterators...
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
Represents analyses that only rely on functions' control flow.
This is the base class for all instructions that perform data casts.
Instruction::CastOps getOpcode() const
Return the opcode of this CastInst.
static LLVM_ABI CastInst * Create(Instruction::CastOps, Value *S, Type *Ty, const Twine &Name="", InsertPosition InsertBefore=nullptr)
Provides a way to construct any of the CastInst subclasses using an opcode instead of the subclass's ...
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
@ FCMP_OEQ
0 0 0 1 True if ordered and equal
@ ICMP_SLT
signed less than
@ ICMP_SLE
signed less or equal
@ FCMP_OLT
0 1 0 0 True if ordered and less than
@ FCMP_ULE
1 1 0 1 True if unordered, less than, or equal
@ FCMP_OGT
0 0 1 0 True if ordered and greater than
@ FCMP_OGE
0 0 1 1 True if ordered and greater than or equal
@ ICMP_SGT
signed greater than
@ FCMP_ULT
1 1 0 0 True if unordered or less than
@ FCMP_ONE
0 1 1 0 True if ordered and operands are unequal
@ FCMP_UEQ
1 0 0 1 True if unordered or equal
@ ICMP_ULT
unsigned less than
@ FCMP_UGT
1 0 1 0 True if unordered or greater than
@ FCMP_OLE
0 1 0 1 True if ordered and less than or equal
@ ICMP_SGE
signed greater or equal
@ FCMP_UNE
1 1 1 0 True if unordered or not equal
@ ICMP_ULE
unsigned less or equal
@ FCMP_UGE
1 0 1 1 True if unordered, greater than, or equal
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE,...
static LLVM_ABI StringRef getPredicateName(Predicate P)
Predicate getPredicate() const
Return the predicate for this instruction.
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
Conditional Branch instruction.
void setCondition(Value *V)
Value * getCondition() const
BasicBlock * getSuccessor(unsigned i) const
iterator_range< succ_iterator > successors()
static ConstantInt * getSigned(IntegerType *Ty, int64_t V, bool ImplicitTrunc=false)
Return a ConstantInt with the specified value for the specified type.
This is an important base class in LLVM.
A parsed version of the target data layout string in and methods for querying it.
bool isLegalInteger(uint64_t Width) const
Returns true if the specified type is known to be a native integer type supported by the CPU.
static DebugLoc getDropped()
bool properlyDominates(const DomTreeNodeBase< NodeT > *A, const DomTreeNodeBase< NodeT > *B) const
properlyDominates - Returns true iff A dominates B and A != B.
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
LLVM_ABI bool dominates(const BasicBlock *BB, const Use &U) const
Return true if the (end of the) basic block BB dominates the use U.
This instruction compares its operands according to the predicate given to the constructor.
This instruction compares its operands according to the predicate given to the constructor.
CmpPredicate getCmpPredicate() const
CmpPredicate getInverseCmpPredicate() const
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
LLVM_ABI PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U)
const DebugLoc & getDebugLoc() const
Return the debug location for this node as a DebugLoc.
Instruction * user_back()
iterator_range< user_iterator > users()
unsigned getOpcode() const
Returns a member of one of the enums like Instruction::Add.
void setDebugLoc(DebugLoc Loc)
Set the debug location information for this instruction.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this instruction belongs to.
Class to represent integer types.
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
bool replacementPreservesLCSSAForm(Instruction *From, Value *To)
Returns true if replacing From with To everywhere is guaranteed to preserve LCSSA form.
Represents a single loop in the control flow graph.
An analysis that produces MemorySSA for a function.
Encapsulates MemorySSA, including all data associated with memory accesses.
Represent a mutable reference to an array (0 or more elements consecutively in memory),...
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
void setIncomingValue(unsigned i, Value *V)
Value * getIncomingValueForBlock(const BasicBlock *BB) const
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
Value * getIncomingValue(unsigned i) const
Return incoming value number x.
static unsigned getIncomingValueNumForOperand(unsigned i)
unsigned getNumIncomingValues() const
Return the number of incoming edges.
static PHINode * Create(Type *Ty, unsigned NumReservedValues, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
Constructors - NumReservedValues is a hint for the number of incoming edges that this phi node will h...
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
A set of analyses that are preserved following a run of a transformation pass.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
This node represents a polynomial recurrence on the trip count of the specified loop.
LLVM_ABI const SCEV * evaluateAtIteration(const SCEV *It, ScalarEvolution &SE) const
Return the value of this chain of recurrences at the specified iteration number.
LLVM_ABI const SCEVAddRecExpr * getPostIncExpr(ScalarEvolution &SE) const
Return an expression representing the value of this expression one iteration of the loop ahead.
SCEVUse getStepRecurrence(ScalarEvolution &SE) const
Constructs and returns the recurrence indicating how much this expression steps by.
This class uses information about analyze scalars to rewrite expressions in canonical form.
bool hasNoUnsignedWrap() const
bool hasNoSignedWrap() const
This class represents an analyzed expression in the program.
LLVM_ABI bool isOne() const
Return true if the expression is a constant one.
LLVM_ABI bool isZero() const
Return true if the expression is a constant zero.
Type * getType() const
Return the LLVM type of this SCEV expression.
This class represents a cast from signed integer to floating point.
The main scalar evolution driver.
LLVM_ABI std::optional< LoopInvariantPredicate > getLoopInvariantExitCondDuringFirstIterations(CmpPredicate Pred, const SCEV *LHS, const SCEV *RHS, const Loop *L, const Instruction *CtxI, const SCEV *MaxIter)
If the result of the predicate LHS Pred RHS is loop invariant with respect to L at given Context duri...
LLVM_ABI Type * getWiderType(Type *Ty1, Type *Ty2) const
LLVM_ABI bool isLoopEntryGuardedByCond(const Loop *L, CmpPredicate Pred, const SCEV *LHS, const SCEV *RHS)
Test whether entry to the loop is protected by a conditional between LHS and RHS.
LLVM_ABI const SCEV * getBackedgeTakenCount(const Loop *L, ExitCountKind Kind=Exact)
If the specified loop has a predictable backedge-taken count, return it, otherwise return a SCEVCould...
LLVM_ABI const SCEV * getMinusSCEV(SCEVUse LHS, SCEVUse RHS, SCEVFlags Flags=SCEV::FlagNone, unsigned Depth=0)
Return LHS-RHS.
LLVM_ABI ExitLimit computeExitLimitFromCond(const Loop *L, Value *ExitCond, bool ExitIfTrue, bool ControlsOnlyExit, bool AllowPredicates=false)
Compute the number of times the backedge of the specified loop will execute if its exit condition wer...
LLVM_ABI SCEVUse getSCEVAtScope(const SCEV *S, const Loop *L)
Return a SCEV expression for the specified value at the specified scope in the program.
LLVM_ABI uint64_t getTypeSizeInBits(Type *Ty) const
Return the size in bits of the specified type, for which isSCEVable must return true.
LLVM_ABI const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
const SCEV * getOne(Type *Ty)
Return a SCEV for the constant 1 of a specific type.
LLVM_ABI void forgetValues(ArrayRef< Value * > Values)
Batched forgetValue: invalidates all Values in one shared def-use walk, avoiding the redundant re-tra...
LLVM_ABI std::optional< bool > evaluatePredicateAt(CmpPredicate Pred, const SCEV *LHS, const SCEV *RHS, const Instruction *CtxI)
Check whether the condition described by Pred, LHS, and RHS is true or false in the given Context.
LLVM_ABI void forgetLoop(const Loop *L)
This method should be called by the client when it has changed a loop in a way that may effect Scalar...
LLVM_ABI bool isLoopInvariant(const SCEV *S, const Loop *L)
Return true if the value of the given SCEV is unchanging in the specified loop.
LLVM_ABI const SCEV * getTruncateExpr(SCEVUse Op, Type *Ty, unsigned Depth=0)
LLVM_ABI bool isSCEVable(Type *Ty) const
Test if values of the given type are analyzable within the SCEV framework.
LLVM_ABI Type * getEffectiveSCEVType(Type *Ty) const
Return a type with the same bitwidth as the given type and which represents how SCEV will treat the g...
ConstantRange getUnsignedRange(const SCEV *S)
Determine the unsigned range for a particular SCEV.
LLVM_ABI void forgetTopmostLoop(const Loop *L)
LLVM_ABI void forgetValue(Value *V)
This method should be called by the client when it has changed a value in a way that may effect its v...
const SCEV * getMinusOne(Type *Ty)
Return a SCEV for the constant -1 of a specific type.
LLVM_ABI SCEVUse getZeroExtendExpr(SCEVUse Op, Type *Ty, unsigned Depth=0)
LLVM_ABI const SCEV * getNoopOrZeroExtend(const SCEV *V, Type *Ty)
Return a SCEV corresponding to a conversion of the input value to the specified type.
LLVM_ABI const SCEV * getUMinFromMismatchedTypes(const SCEV *LHS, const SCEV *RHS, bool Sequential=false)
Promote the operands to the wider of the types using zero-extension, and then perform a umin operatio...
LLVM_ABI const SCEV * getCouldNotCompute()
LLVM_ABI const SCEV * getExitCount(const Loop *L, const BasicBlock *ExitingBlock, ExitCountKind Kind=Exact)
Return the number of times the backedge executes before the given exit would be taken; if not exactly...
LLVM_ABI SCEVUse getSignExtendExpr(SCEVUse Op, Type *Ty, unsigned Depth=0)
@ SymbolicMaximum
An expression which provides an upper bound on the exact trip count.
LLVM_ABI const SCEV * applyLoopGuards(const SCEV *Expr, const Loop *L)
Try to apply information from loop guards for L to Expr.
LLVM_ABI bool isKnownPredicateAt(CmpPredicate Pred, const SCEV *LHS, const SCEV *RHS, const Instruction *CtxI)
Test if the given expression is known to satisfy the condition described by Pred, LHS,...
const SCEV * getSymbolicMaxBackedgeTakenCount(const Loop *L)
When successful, this returns a SCEV that is greater than or equal to (i.e.
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
bool erase(PtrType Ptr)
Remove pointer from the set.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
Provides information about what library functions are available for the current target.
The instances of the Type class are immutable: once they are created, they are never changed.
static LLVM_ABI IntegerType * getInt32Ty(LLVMContext &C)
bool isPointerTy() const
True if this is an instance of PointerType.
bool isIntegerTy() const
True if this is an instance of IntegerType.
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
bool hasOneUse() const
Return true if there is exactly one use of this value.
LLVM_ABI void replaceAllUsesWith(Value *V)
Change all uses of this to point to a new Value.
LLVMContext & getContext() const
All values hold a context through their type.
LLVM_ABI StringRef getName() const
Return a constant reference to the value's name.
LLVM_ABI void takeName(Value *V)
Transfer the name from V to this value.
Value handle that is nullable, but tries to track the Value.
const ParentTy * getParent() const
self_iterator getIterator()
This provides a very simple, boring adaptor for a begin and end iterator into a range type.
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
@ BasicBlock
Various leaf nodes.
LLVM_ABI Function * getDeclarationIfExists(const Module *M, ID id)
Look up the Function declaration of the intrinsic id in the Module M and return it if it exists.
auto m_Value()
Match an arbitrary value and ignore it.
auto m_LogicalOr()
Matches L || R where L and R are arbitrary values.
CastInst_match< OpTy, ZExtInst > m_ZExt(const OpTy &Op)
Matches ZExt.
auto m_LogicalAnd()
Matches L && R where L and R are arbitrary values.
cst_pred_ty< is_one > m_scev_One()
Match an integer 1.
specificloop_ty m_SpecificLoop(const Loop *L)
bool match(const SCEV *S, const Pattern &P)
SCEVAffineAddRec_match< Op0_t, Op1_t, match_isa< const Loop > > m_scev_AffineAddRec(const Op0_t &Op0, const Op1_t &Op1)
PointerTypeMap run(const Module &M)
Compute the PointerTypeMap for the module M.
@ User
could "use" a pointer
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
LLVM_ABI bool mustExecuteUBIfPoisonOnPathTo(Instruction *Root, Instruction *OnPathTo, DominatorTree *DT)
Return true if undefined behavior would provable be executed on the path to OnPathTo if Root produced...
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI bool RecursivelyDeleteTriviallyDeadInstructions(Value *V, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, std::function< void(Value *)> AboutToDeleteCallback=std::function< void(Value *)>())
If the specified value is a trivially dead instruction, delete it.
LLVM_ABI Value * simplifyInstruction(Instruction *I, const SimplifyQuery &Q, SmallVectorImpl< Instruction * > *DropAnnotations=nullptr)
See if we can compute a simplified version of this instruction.
constexpr bool isInt(int64_t x)
Checks if an integer fits into the given bit width.
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI PHINode * createWideIV(const WideIVInfo &WI, LoopInfo *LI, ScalarEvolution *SE, SCEVExpander &Rewriter, DominatorTree *DT, SmallVectorImpl< WeakTrackingVH > &DeadInsts, unsigned &NumElimExt, unsigned &NumWidened, bool HasGuards, bool UsePostIncrementRanges)
Widen Induction Variables - Extend the width of an IV to cover its widest uses.
SCEVUseT< const SCEV * > SCEVUse
LLVM_ABI bool DeleteDeadPHIs(BasicBlock *BB, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, SmallPtrSetImpl< PHINode * > *KnownNonDeadPHIs=nullptr)
Examine each PHI in the given block and delete it if it is dead.
constexpr bool isUIntN(unsigned N, uint64_t x)
Checks if an unsigned integer fits into the given (dynamic) bit width.
iterator_range< early_inc_iterator_impl< detail::IterOfRange< RangeT > > > make_early_inc_range(RangeT &&Range)
Make a range that does early increment to allow mutation of the underlying range without disrupting i...
const ScalarOptions & getScalarOptions(const LLVMContext &C)
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
AnalysisManager< Loop, LoopStandardAnalysisResults & > LoopAnalysisManager
The loop analysis manager.
auto dyn_cast_or_null(const Y &Val)
auto reverse(ContainerTy &&C)
void sort(IteratorTy Start, IteratorTy End)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
IRBuilder(LLVMContext &, FolderTy, InserterTy) -> IRBuilder< FolderTy, InserterTy >
constexpr uint64_t alignTo(uint64_t Size, Align A)
Returns a multiple of A needed to store Size bytes.
LLVM_ABI cl::opt< unsigned > SCEVCheapExpansionBudget
LLVM_ABI bool RecursivelyDeleteDeadPHINode(PHINode *PN, const TargetLibraryInfo *TLI=nullptr, MemorySSAUpdater *MSSAU=nullptr, SmallPtrSetImpl< PHINode * > *KnownNonDeadPHIs=nullptr)
If the specified value is an effectively dead PHI node, due to being a def-use chain of single-use no...
LLVM_ABI bool VerifyMemorySSA
Enables verification of MemorySSA.
class LLVM_GSL_OWNER SmallVector
Forward declaration of SmallVector so that calculateSmallVectorDefaultInlinedElements can reference s...
bool isa(const From &Val)
isa<X> - Return true if the parameter to the template is an instance of one of the template type argu...
LLVM_ABI std::pair< bool, bool > simplifyUsersOfIV(PHINode *CurrIV, ScalarEvolution *SE, DominatorTree *DT, LoopInfo *LI, const TargetTransformInfo *TTI, SmallVectorImpl< WeakTrackingVH > &Dead, SCEVExpander &Rewriter, IVVisitor *V=nullptr)
simplifyUsersOfIV - Simplify instructions that use this induction variable by using ScalarEvolution t...
LLVM_ABI bool isLoopNestFinite(Loop *L, ScalarEvolution &SE, const LoopInfo &LI)
Return true if every cycle in the loop nest rooted at L is finite.
RNSuccIterator< NodeRef, BlockT, RegionT > succ_begin(NodeRef Node)
@ UMin
Unsigned integer min implemented in terms of select(cmp()).
DWARFExpression::Operation Op
constexpr U AbsoluteValue(T X)
Return the absolute value of a signed integer, converted to the corresponding unsigned integer type.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
decltype(auto) cast(const From &Val)
cast<X> - Return the argument parameter cast to the specified type.
LLVM_ABI PreservedAnalyses getLoopPassPreservedAnalyses()
Returns the minimum set of Analyses that all loop passes must preserve.
auto find_if(R &&Range, UnaryPredicate P)
Provide wrappers to std::find_if which take ranges instead of having to pass begin/end explicitly.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
LLVM_ABI bool isAlmostDeadIV(PHINode *IV, BasicBlock *LatchBlock, Value *Cond)
Return true if the induction variable IV in a Loop whose latch is LatchBlock would become dead if the...
LLVM_ABI int rewriteLoopExitValues(Loop *L, LoopInfo *LI, TargetLibraryInfo *TLI, ScalarEvolution *SE, const TargetTransformInfo *TTI, SCEVExpander &Rewriter, DominatorTree *DT, ReplaceExitVal ReplaceExitValue, SmallVector< WeakTrackingVH, 16 > &DeadInsts)
If the final value of any expressions that are recurrent in the loop can be computed,...
iterator_range< pointer_iterator< WrappedIteratorT > > make_pointer_range(RangeT &&Range)
Implement std::hash so that hash_code can be used in STL containers.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
Represents a floating-point induction variable pattern that may be convertible to integer form.
FloatingPointIV(APFloat Init, APFloat Incr, APFloat Exit, FCmpInst *Compare, bool ExitsOnTrue)
Represents the integer values for a converted IV.
CmpInst::Predicate NewPred
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
TargetTransformInfo & TTI
Collect information about induction variables that are used by sign/zero extend operations.