96#define DEBUG_TYPE "licm"
98STATISTIC(NumSunk,
"Number of instructions sunk out of loop");
99STATISTIC(NumHoisted,
"Number of instructions hoisted out of loop");
100STATISTIC(NumMovedLoads,
"Number of load insts hoisted or sunk");
101STATISTIC(NumMovedCalls,
"Number of call insts hoisted or sunk");
102STATISTIC(NumPromotionCandidates,
"Number of promotion candidates");
103STATISTIC(NumLoadPromoted,
"Number of load-only promotions");
104STATISTIC(NumLoadStorePromoted,
"Number of load and store promotions");
106 "Number of min/max expressions hoisted out of the loop");
108 "Number of geps reassociated and hoisted out of the loop");
109STATISTIC(NumAddSubHoisted,
"Number of add/subtract expressions reassociated "
110 "and hoisted out of the loop");
111STATISTIC(NumFPAssociationsHoisted,
"Number of invariant FP expressions "
112 "reassociated and hoisted out of the loop");
114 "Number of invariant int expressions "
115 "reassociated and hoisted out of the loop");
116STATISTIC(NumBOAssociationsHoisted,
"Number of invariant BinaryOp expressions "
117 "reassociated and hoisted out of the loop");
122 .licm_mssa_optimization_cap;
128 .licm_mssa_max_acc_promotion;
135 bool &FoldableInLoop,
bool LoopNestMode);
154 bool InvariantGroup);
181 std::pair<SmallSetVector<Value *, 8>,
bool>;
188struct LoopInvariantCodeMotion {
194 LoopInvariantCodeMotion(
const ScalarOptions &Opts,
const LICMOptions &LO)
196 LicmMssaOptCap(LO.MssaOptCap.value_or(Opts.licm_mssa_optimization_cap)),
197 LicmMssaNoAccForPromotionCap(LO.MssaNoAccForPromotionCap.value_or(
198 Opts.licm_mssa_max_acc_promotion)),
199 LicmAllowSpeculation(LO.AllowSpeculation) {}
202 const ScalarOptions &Opts;
203 unsigned LicmMssaOptCap;
204 unsigned LicmMssaNoAccForPromotionCap;
205 bool LicmAllowSpeculation;
208struct LegacyLICMPass :
public LoopPass {
210 LegacyLICMPass() : LoopPass(
ID) {
214 bool runOnLoop(
Loop *L, LPPassManager &LPM)
override {
219 <<
L->getHeader()->getNameOrAsOperand() <<
"\n");
223 auto *SE = getAnalysisIfAvailable<ScalarEvolutionWrapperPass>();
224 MemorySSA *MSSA = &getAnalysis<MemorySSAWrapperPass>().getMSSA();
228 OptimizationRemarkEmitter ORE(
L->getHeader()->getParent());
230 LoopInvariantCodeMotion LICM(Opts, LICMOptions());
231 return LICM.runOnLoop(
232 L, &getAnalysis<AAResultsWrapperPass>().getAAResults(),
233 &getAnalysis<LoopInfoWrapperPass>().getLoopInfo(),
234 &getAnalysis<DominatorTreeWrapperPass>().
getDomTree(),
235 &getAnalysis<AssumptionCacheTracker>().getAssumptionCache(*
F),
236 &getAnalysis<TargetLibraryInfoWrapperPass>().getTLI(*
F),
237 &getAnalysis<TargetTransformInfoWrapperPass>().getTTI(*
F),
238 SE ? &SE->getSE() :
nullptr, MSSA, &ORE);
244 void getAnalysisUsage(AnalysisUsage &AU)
const override {
271 if (!LICM.runOnLoop(&L, &AR.
AA, &AR.
LI, &AR.
DT, &AR.
AC, &AR.
TLI, &AR.
TTI,
284 OS, MapClassName2PassName);
287 OS << (Opts.AllowSpeculation ?
"" :
"no-") <<
"allowspeculation";
305 bool Changed = LICM.runOnLoop(&OutermostLoop, &AR.
AA, &AR.
LI, &AR.
DT, &AR.
AC,
322 static_cast<PassInfoMixin<LNICMPass> *
>(
this)->
printPipeline(
323 OS, MapClassName2PassName);
326 OS << (Opts.AllowSpeculation ?
"" :
"no-") <<
"allowspeculation";
330char LegacyLICMPass::ID = 0;
355 unsigned AccessCapCount = 0;
356 for (
auto *BB : L.getBlocks())
380 assert(L->isLCSSAForm(*DT) &&
"Loop is not in LCSSA form.");
397 bool HasCoroSuspendInst =
false;
409 for (
const MDOperand &
Op : Decl->getScopeList()->operands())
433 if (
L->hasDedicatedExits())
437 TLI,
TTI, L, MSSAU, &SafetyInfo, Flags, ORE)
439 MSSAU, &SafetyInfo,
Flags, ORE);
440 Flags.setIsSink(
false);
443 MSSAU, SE, &SafetyInfo, Flags, ORE, LoopNestMode,
444 LicmAllowSpeculation);
453 if (!Opts.disable_licm_promotion && Preheader &&
L->hasDedicatedExits() &&
454 !
Flags.tooManyMemoryAccesses() && !HasCoroSuspendInst) {
456 SmallVector<BasicBlock *, 8> ExitBlocks;
457 L->getUniqueExitBlocks(ExitBlocks);
460 bool HasCatchSwitch = llvm::any_of(ExitBlocks, [](BasicBlock *Exit) {
461 return isa<CatchSwitchInst>(Exit->getTerminator());
464 if (!HasCatchSwitch) {
467 InsertPts.
reserve(ExitBlocks.size());
468 MSSAInsertPts.
reserve(ExitBlocks.size());
473 bool Promoted =
false;
476 LocalPromoted =
false;
482 MSSAInsertPts.
clear();
484 InsertPts.
push_back(ExitBlock->getFirstInsertionPt());
488 for (
auto [PointerMustAliases, HasReadsOutsideSet] :
490 LoopLocalAliasScopes, L)) {
492 PointerMustAliases, ExitBlocks, InsertPts, MSSAInsertPts,
PIC, LI,
493 DT, AC, TLI,
TTI, L, MSSAU, &SafetyInfo, ORE,
494 LicmAllowSpeculation, HasReadsOutsideSet);
496 Promoted |= LocalPromoted;
497 }
while (LocalPromoted);
515 assert(
L->isLCSSAForm(*DT) &&
"Loop not left in LCSSA form after LICM!");
516 assert((
L->isOutermost() ||
L->getParentLoop()->isLCSSAForm(*DT)) &&
517 "Parent loop not left in LCSSA form after LICM!");
540 assert(
N !=
nullptr &&
AA !=
nullptr && LI !=
nullptr && DT !=
nullptr &&
541 CurLoop !=
nullptr && SafetyInfo !=
nullptr &&
542 "Unexpected input to sinkRegion.");
576 bool FoldableInLoop =
false;
577 bool LoopNestMode = OutermostLoop !=
nullptr;
578 if (!
I.mayHaveSideEffects() &&
580 SafetyInfo,
TTI, FoldableInLoop,
583 if (
sink(
I, LI, DT, CurLoop, SafetyInfo, MSSAU, ORE)) {
584 if (!FoldableInLoop) {
611 while (!Worklist.
empty()) {
614 MSSAU, SafetyInfo, Flags, ORE, CurLoop);
631 bool AllowSpeculation) {
633 assert(
N !=
nullptr &&
AA !=
nullptr && LI !=
nullptr && DT !=
nullptr &&
634 CurLoop !=
nullptr && SafetyInfo !=
nullptr &&
635 "Unexpected input to hoistRegion.");
645 if (!LoopNestMode &&
inSubLoop(BB, CurLoop, LI))
657 hoist(
I, DT, CurLoop, Preheader, SafetyInfo, MSSAU, SE, ORE);
671 if (
I.getOpcode() == Instruction::FDiv &&
I.hasAllowReciprocal() &&
673 auto Divisor =
I.getOperand(1);
674 auto One = llvm::ConstantFP::get(Divisor->getType(), 1.0);
675 auto ReciprocalDivisor = BinaryOperator::CreateFDiv(One, Divisor);
676 ReciprocalDivisor->setFastMathFlags(
I.getFastMathFlags());
678 ReciprocalDivisor->insertBefore(
I.getIterator());
679 ReciprocalDivisor->setDebugLoc(
I.getDebugLoc());
682 BinaryOperator::CreateFMul(
I.getOperand(0), ReciprocalDivisor);
683 Product->setFastMathFlags(
I.getFastMathFlags());
685 Product->insertAfter(
I.getIterator());
686 Product->setDebugLoc(
I.getDebugLoc());
687 I.replaceAllUsesWith(Product);
690 hoist(*ReciprocalDivisor, DT, CurLoop, Preheader, SafetyInfo, MSSAU, SE,
698 return I.use_empty() &&
701 auto MustExecuteWithoutWritesBefore = [&](
Instruction &
I) {
705 if ((IsInvariantStart(
I) ||
isGuard(&
I)) &&
707 MustExecuteWithoutWritesBefore(
I)) {
708 hoist(
I, DT, CurLoop, Preheader, SafetyInfo, MSSAU, SE, ORE);
727#ifdef EXPENSIVE_CHECKS
729 assert(DT->
verify(DominatorTree::VerificationLevel::Fast) &&
730 "Dominator tree verification failed");
738static std::optional<uint64_t>
747 if (InsertedIdxCI->isNegative() ||
748 InsertedIdxCI->getValue().uge(
749 VecTy->getElementCount().getKnownMinValue()))
751 return InsertedIdxCI->getValue().getLimitedValue();
781 if (!InnerIns || InnerIns->getParent() != Ins->
getParent())
786 if (!InsertIdx || *InsertIdx == *HoistIdx)
790 if (!InnerIns->hasOneUse())
805 hoist(*Ins, DT, CurLoop, HoistDest, SafetyInfo, MSSAU, SE, ORE);
837 unsigned UsesVisited = 0;
840 for (
auto *U : Addr->
users()) {
842 if (++UsesVisited > Opts.licm_max_num_uses_traversed)
847 if (!
II ||
II->getIntrinsicID() != Intrinsic::invariant_start ||
885 for (
auto *BB : L->getBlocks())
888 for (
const auto &Acc : *Accs) {
892 if (MUD->getMemoryInst() !=
I || NotAPhi++ == 1)
904 if (Flags.tooManyClobberingCalls())
909 Flags.incrementClobberingCalls();
915 bool TargetExecutesOncePerLoop,
925 if (LI.
hasMetadata(LLVMContext::MD_invariant_load))
928 if (LI.
isAtomic() && !TargetExecutesOncePerLoop)
937 bool InvariantGroup = LI.
hasMetadata(LLVMContext::MD_invariant_group);
946 DEBUG_TYPE,
"LoadWithLoopInvariantAddressInvalidated", &LI)
947 <<
"failed to move load with loop-invariant address "
948 "because the loop may invalidate its value";
956 bool TargetExecutesOncePerLoop,
966 return canHoistLoad(*LI,
AA, DT, CurLoop, *MSSA, TargetExecutesOncePerLoop,
977 if (CI->isConvergent())
985 if (CI->getFunction()->isPresplitCoroutine())
1008 MSSA, MU, CurLoop,
I, Flags,
false);
1023 if (!
SI->isUnordered())
1036 assert(!
I.mayReadOrWriteMemory() &&
"unhandled aliasing");
1068 for (
const User *U :
GEP->users()) {
1090 bool &FoldableInLoop,
bool LoopNestMode) {
1092 for (
const User *U :
I.users()) {
1104 if (!BlockColors.empty() &&
1105 BlockColors.find(
const_cast<BasicBlock *
>(BB))->second.size() != 1)
1121 FoldableInLoop =
true;
1141 for (
unsigned BundleIdx = 0, BundleEnd = CI->getNumOperandBundles();
1142 BundleIdx != BundleEnd; ++BundleIdx) {
1150 if (!BlockColors.empty()) {
1151 const ColorVector &CV = BlockColors.find(&ExitBlock)->second;
1152 assert(CV.
size() == 1 &&
"non-unique color for exit block!");
1155 if (EHPad->isEHPad())
1160 New->copyMetadata(*CI);
1166 if (!
I.getName().empty())
1167 New->setName(
I.getName() +
".le");
1193 for (
Use &
Op : New->operands())
1198 OInst->getName() +
".lcssa");
1211 I.eraseFromParent();
1220 I.moveBefore(*Dest->getParent(), Dest);
1235 "Expect only trivially replaceable PHI");
1237 auto [It, Inserted] = SunkCopies.
try_emplace(ExitBlock);
1272 assert(ExitBlockSet.
count(ExitBB) &&
"Expect the PHI is in an exit block.");
1309 while (!PredBBs.
empty()) {
1312 "Expect all predecessors are in the loop");
1315 ExitBB, PredBB,
".split.loop.exit", &DTU, LI, MSSAU,
true);
1319 if (!BlockColors.empty())
1346 Use &U = UI.getUse();
1384 UI =
I.user_begin();
1388 if (VisitedUsers.
empty())
1393 <<
"sinking " <<
ore::NV(
"Inst", &
I);
1416 for (
auto *UI :
Users) {
1424 "The LCSSA PHI is not in an exit block!");
1428 PN, &
I, LI, SunkCopies, SafetyInfo, CurLoop, MSSAU);
1430 New->dropLocation();
1465 I.dropUBImplyingAttrsAndMetadata();
1476 I.updateLocationAfterHoist();
1493 if (AllowSpeculation &&
1499 if (!GuaranteedToExecute) {
1504 DEBUG_TYPE,
"LoadWithLoopInvariantAddressCondExecuted", LI)
1505 <<
"failed to hoist load with loop-invariant address "
1506 "because load is conditionally executed";
1510 return GuaranteedToExecute;
1516 SmallVectorImpl<BasicBlock *> &LoopExitBlocks;
1517 SmallVectorImpl<BasicBlock::iterator> &LoopInsertPts;
1518 SmallVectorImpl<MemoryAccess *> &MSSAInsertPts;
1519 PredIteratorCache &PredCache;
1520 MemorySSAUpdater &MSSAU;
1524 bool UnorderedAtomic;
1526 ICFLoopSafetyInfo &SafetyInfo;
1527 bool CanInsertStoresInExitBlocks;
1533 Value *maybeInsertLCSSAPHI(
Value *V, BasicBlock *BB)
const {
1541 I->getName() +
".lcssa");
1543 for (BasicBlock *Pred : PredCache.
get(BB))
1550 SmallVectorImpl<BasicBlock *> &LEB,
1551 SmallVectorImpl<BasicBlock::iterator> &LIP,
1552 SmallVectorImpl<MemoryAccess *> &MSSAIP, PredIteratorCache &
PIC,
1553 MemorySSAUpdater &MSSAU, LoopInfo &li,
DebugLoc dl,
1554 Align Alignment,
bool UnorderedAtomic,
const AAMDNodes &AATags,
1555 ICFLoopSafetyInfo &SafetyInfo,
bool CanInsertStoresInExitBlocks)
1556 : LoadAndStorePromoter(Insts, S), SomePtr(
SP), LoopExitBlocks(LEB),
1557 LoopInsertPts(LIP), MSSAInsertPts(MSSAIP), PredCache(
PIC), MSSAU(MSSAU),
1559 UnorderedAtomic(UnorderedAtomic), AATags(AATags),
1560 SafetyInfo(SafetyInfo),
1561 CanInsertStoresInExitBlocks(CanInsertStoresInExitBlocks),
Uses(Insts) {}
1563 void insertStoresInLoopExitBlocks() {
1568 DIAssignID *NewID =
nullptr;
1569 for (
unsigned i = 0, e = LoopExitBlocks.
size(); i != e; ++i) {
1571 Value *LiveInValue =
SSA.GetValueInMiddleOfBlock(ExitBlock);
1572 LiveInValue = maybeInsertLCSSAPHI(LiveInValue, ExitBlock);
1573 Value *Ptr = maybeInsertLCSSAPHI(SomePtr, ExitBlock);
1575 StoreInst *NewSI =
new StoreInst(LiveInValue, Ptr, InsertPos);
1576 if (UnorderedAtomic)
1592 NewSI->
setMetadata(LLVMContext::MD_DIAssignID, NewID);
1598 MemoryAccess *MSSAInsertPoint = MSSAInsertPts[i];
1599 MemoryAccess *NewMemAcc;
1600 if (!MSSAInsertPoint) {
1602 NewSI,
nullptr, NewSI->
getParent(), MemorySSA::Beginning);
1607 MSSAInsertPts[i] = NewMemAcc;
1613 void doExtraRewritesBeforeFinalDeletion()
override {
1614 if (CanInsertStoresInExitBlocks)
1615 insertStoresInLoopExitBlocks();
1618 void instructionDeleted(Instruction *
I)
const override {
1623 bool shouldDelete(Instruction *
I)
const override {
1625 return CanInsertStoresInExitBlocks;
1630bool isNotCapturedBeforeOrInLoop(
const Value *V,
const Loop *L,
1637 V,
true,
L->getHeader()->getTerminator(), DT,
1643bool isNotVisibleOnUnwindInLoop(
const Value *Object,
const Loop *L,
1645 bool RequiresNoCaptureBeforeUnwind;
1649 return !RequiresNoCaptureBeforeUnwind ||
1650 isNotCapturedBeforeOrInLoop(Object, L, DT);
1653bool isThreadLocalObject(
const Value *Object,
const Loop *L,
1658 isNotCapturedBeforeOrInLoop(Object, L, DT))
1662 const Module *
M =
L->getHeader()->getModule();
1682 bool HasReadsOutsideSet) {
1684 assert(LI !=
nullptr && DT !=
nullptr && CurLoop !=
nullptr &&
1685 SafetyInfo !=
nullptr &&
1686 "Unexpected Input to promoteLoopAccessesToScalars");
1689 dbgs() <<
"Trying to promote set of must-aliased pointers:\n";
1690 for (
Value *Ptr : PointerMustAliases)
1691 dbgs() <<
" " << *Ptr <<
"\n";
1693 ++NumPromotionCandidates;
1695 Value *SomePtr = *PointerMustAliases.
begin();
1735 bool DereferenceableInPH =
false;
1736 bool StoreIsGuaranteedToExecute =
false;
1737 bool LoadIsGuaranteedToExecute =
false;
1738 bool FoundLoadToPromote =
false;
1745 } StoreSafety = StoreSafetyUnknown;
1753 bool SawUnorderedAtomic =
false;
1754 bool SawNotAtomic =
false;
1761 if (HasReadsOutsideSet)
1762 StoreSafety = StoreUnsafe;
1771 if (!isNotVisibleOnUnwindInLoop(Object, CurLoop, DT))
1772 StoreSafety = StoreUnsafe;
1778 Type *AccessTy =
nullptr;
1779 for (
Value *ASIV : PointerMustAliases) {
1789 if (!
Load->isUnordered())
1792 SawUnorderedAtomic |=
Load->isAtomic();
1793 SawNotAtomic |= !
Load->isAtomic();
1794 FoundLoadToPromote =
true;
1798 if (!LoadIsGuaranteedToExecute)
1799 LoadIsGuaranteedToExecute =
1806 if (!DereferenceableInPH || (InstAlignment > Alignment))
1808 *
Load, DT, TLI, CurLoop, SafetyInfo, ORE,
1810 DereferenceableInPH =
true;
1811 Alignment = std::max(Alignment, InstAlignment);
1818 if (!
Store->isUnordered())
1821 SawUnorderedAtomic |=
Store->isAtomic();
1822 SawNotAtomic |= !
Store->isAtomic();
1831 StoreIsGuaranteedToExecute |= GuaranteedToExecute;
1832 if (GuaranteedToExecute) {
1833 DereferenceableInPH =
true;
1834 if (StoreSafety == StoreSafetyUnknown)
1835 StoreSafety = StoreSafe;
1836 Alignment = std::max(Alignment, InstAlignment);
1845 if (StoreSafety == StoreSafetyUnknown &&
1849 StoreSafety = StoreSafe;
1853 if (!DereferenceableInPH) {
1855 Store->getPointerOperand(),
Store->getValueOperand()->getType(),
1868 if (LoopUses.
empty()) {
1871 }
else if (AATags) {
1883 if (SawUnorderedAtomic && SawNotAtomic)
1893 if (!DereferenceableInPH) {
1894 LLVM_DEBUG(
dbgs() <<
"Not promoting: Not dereferenceable in preheader\n");
1902 if (StoreSafety == StoreSafetyUnknown) {
1904 bool ExplicitlyDereferenceableOnly;
1909 (!ExplicitlyDereferenceableOnly ||
1912 isThreadLocalObject(Object, CurLoop, DT))
1913 StoreSafety = StoreSafe;
1918 if (StoreSafety != StoreSafe && !FoundLoadToPromote)
1923 if (StoreSafety == StoreSafe) {
1924 LLVM_DEBUG(
dbgs() <<
"LICM: Promoting load/store of the value: " << *SomePtr
1926 ++NumLoadStorePromoted;
1928 LLVM_DEBUG(
dbgs() <<
"LICM: Promoting load of the value: " << *SomePtr
1936 <<
"Moving accesses to memory location out of the loop";
1940 std::vector<DebugLoc> LoopUsesLocs;
1941 for (
auto U : LoopUses)
1942 LoopUsesLocs.push_back(U->getDebugLoc());
1948 LoopPromoter Promoter(SomePtr, LoopUses,
SSA, ExitBlocks, InsertPts,
1949 MSSAInsertPts,
PIC, MSSAU, *LI,
DL, Alignment,
1951 StoreIsGuaranteedToExecute ? AATags :
AAMDNodes(),
1952 *SafetyInfo, StoreSafety == StoreSafe);
1957 if (FoundLoadToPromote || !StoreIsGuaranteedToExecute) {
1961 if (SawUnorderedAtomic)
1965 if (AATags && LoadIsGuaranteedToExecute)
1972 SSA.AddAvailableValue(Preheader, PreheaderLoad);
1981 Promoter.run(LoopUses);
1986 if (PreheaderLoad && PreheaderLoad->
use_empty())
1998 Fn(MUD->getMemoryInst());
2005 const Value *PtrOp =
SI->getPointerOperand();
2011 const Value *PtrOp = LI->getPointerOperand();
2024 return Operands.contains(cast<MDNode>(Op.get()));
2045 L->getExitingBlocks(ExitingBlocks);
2048 for (
const auto &Pair : StoresByLoc) {
2067 return StoresWithInvariantAATags;
2081 std::optional<SmallPtrSet<const StoreInst *, 8>> StoresWithInvariantAATags;
2082 auto HasInvariantAATags = [&](
const StoreInst *
SI) {
2083 if (!StoresWithInvariantAATags)
2084 StoresWithInvariantAATags =
2086 return StoresWithInvariantAATags->contains(
SI);
2093 AttemptingPromotion.
insert(
I);
2095 SI &&
SI->getAAMetadata() &&
2097 !HasInvariantAATags(
SI)) {
2113 if (!AS.isForwardingAliasSet() && AS.isMod() && AS.isMustAlias())
2141 for (
auto [Set, HasReadsOutsideSet] : Sets) {
2143 for (
const auto &MemLoc : *Set)
2144 PointerMustAliases.
insert(
const_cast<Value *
>(MemLoc.Ptr));
2145 Result.emplace_back(std::move(PointerMustAliases), HasReadsOutsideSet);
2160 if (Flags.tooManyMemoryAccesses())
2179 if (!Flags.getIsSink() && MSSA->
dominates(IMD, &MA))
2197 bool InvariantGroup) {
2199 if (!Flags.getIsSink()) {
2212 CurLoop->
contains(Source->getBlock()) &&
2233 if (Flags.tooManyMemoryAccesses())
2261 Value *Cond1, *Cond2;
2273 if (!
LHS->getType()->isIntegerTy())
2277 if (L.isLoopInvariant(
LHS)) {
2281 if (L.isLoopInvariant(
LHS) || !L.isLoopInvariant(
RHS))
2288 Value *LHS1, *LHS2, *RHS1, *RHS2;
2289 if (!MatchICmpAgainstInvariant(Cond1, P1, LHS1, RHS1) ||
2290 !MatchICmpAgainstInvariant(Cond2, P2, LHS2, RHS2))
2293 if (!MatchingPred || LHS1 != LHS2)
2301 "Relational predicate is either less (or equal) or greater (or equal)!");
2303 ? (UseMin ? Intrinsic::smin : Intrinsic::smax)
2304 : (UseMin ? Intrinsic::umin : Intrinsic::umax);
2305 auto *Preheader = L.getLoopPreheader();
2306 assert(Preheader &&
"Loop is not in simplify form?");
2313 RHS2 = Builder.CreateFreeze(RHS2, RHS2->
getName() +
".fr");
2314 Value *NewRHS = Builder.CreateBinaryIntrinsic(
2315 id, RHS1, RHS2,
nullptr,
2318 (UseMin ?
"min" :
"max"));
2319 Builder.SetInsertPoint(&
I);
2323 Value *NewCond = Builder.CreateICmp(
P, LHS1, NewRHS);
2325 I.replaceAllUsesWith(NewCond);
2348 if (
GEP->hasAllConstantIndices())
2352 if (!Src || !Src->hasOneUse() || !L.contains(Src))
2355 Value *SrcPtr = Src->getPointerOperand();
2356 auto LoopInvariant = [&](
Value *V) {
return L.isLoopInvariant(V); };
2357 if (!L.isLoopInvariant(SrcPtr) || !
all_of(
GEP->indices(), LoopInvariant))
2364 if (
all_of(Src->indices(), LoopInvariant))
2374 bool IsInBounds = Src->isInBounds() &&
GEP->isInBounds() &&
2378 BasicBlock *Preheader = L.getLoopPreheader();
2380 Value *NewSrc = Builder.CreateGEP(
GEP->getSourceElementType(), SrcPtr,
2382 "invariant.gep", IsInBounds);
2383 Builder.SetInsertPoint(
GEP);
2384 Value *NewGEP = Builder.CreateGEP(Src->getSourceElementType(), NewSrc,
2387 GEP->replaceAllUsesWith(NewGEP);
2400 assert(!L.isLoopInvariant(VariantLHS) &&
"Precondition.");
2401 assert(L.isLoopInvariant(InvariantRHS) &&
"Precondition.");
2407 Value *VariantOp, *InvariantOp;
2417 if (L.isLoopInvariant(VariantOp))
2419 if (L.isLoopInvariant(VariantOp) || !L.isLoopInvariant(InvariantOp))
2426 auto &
DL = L.getHeader()->getDataLayout();
2435 auto *Preheader = L.getLoopPreheader();
2436 assert(Preheader &&
"Loop is not in simplify form?");
2439 Builder.CreateSub(InvariantRHS, InvariantOp,
"invariant.op",
2440 !IsSigned, IsSigned);
2461 assert(!L.isLoopInvariant(VariantLHS) &&
"Precondition.");
2462 assert(L.isLoopInvariant(InvariantRHS) &&
"Precondition.");
2468 Value *VariantOp, *InvariantOp;
2476 bool VariantSubtracted =
false;
2480 if (L.isLoopInvariant(VariantOp)) {
2482 VariantSubtracted =
true;
2485 if (L.isLoopInvariant(VariantOp) || !L.isLoopInvariant(InvariantOp))
2493 auto &
DL = L.getHeader()->getDataLayout();
2495 if (VariantSubtracted && IsSigned) {
2500 }
else if (VariantSubtracted && !IsSigned) {
2505 }
else if (!VariantSubtracted && IsSigned) {
2516 auto *Preheader = L.getLoopPreheader();
2517 assert(Preheader &&
"Loop is not in simplify form?");
2521 ? Builder.CreateSub(InvariantOp, InvariantRHS,
"invariant.op",
2522 !IsSigned, IsSigned)
2523 : Builder.CreateAdd(InvariantOp, InvariantRHS,
"invariant.op",
2524 !IsSigned, IsSigned);
2549 if (L.isLoopInvariant(
LHS)) {
2555 if (L.isLoopInvariant(
LHS) || !L.isLoopInvariant(
RHS) || !
LHS->hasOneUse())
2570 unsigned FPOpcode) {
2571 if (
I->getOpcode() == IntOpcode)
2573 if (
I->getOpcode() == FPOpcode &&
I->hasAllowReassoc() &&
2574 I->hasNoSignedZeros())
2590 Value *VariantOp =
I.getOperand(0);
2591 Value *InvariantOp =
I.getOperand(1);
2592 if (L.isLoopInvariant(VariantOp))
2594 if (L.isLoopInvariant(VariantOp) || !L.isLoopInvariant(InvariantOp))
2596 Value *Factor = InvariantOp;
2604 while (!Worklist.
empty()) {
2617 L.isLoopInvariant(BO))
2621 if (L.isLoopInvariant(U0))
2623 else if (L.isLoopInvariant(U1))
2627 unsigned Limit =
I.getType()->isIntOrIntVectorTy()
2628 ? Opts.licm_max_num_int_reassociations
2629 : Opts.licm_max_num_fp_reassociations;
2630 if (Changes.
size() > Limit)
2633 if (Changes.
empty())
2637 if (
I.getType()->isIntOrIntVectorTy()) {
2638 for (
auto *
Add : Adds)
2639 Add->dropPoisonGeneratingFlags();
2643 auto *Preheader = L.getLoopPreheader();
2644 assert(Preheader &&
"Loop is not in simplify form?");
2646 for (
auto *U : Changes) {
2647 assert(L.isLoopInvariant(U->get()));
2650 if (
I.getType()->isIntOrIntVectorTy()) {
2651 Mul = Builder.CreateMul(U->get(), Factor,
"factor.op.mul");
2653 Ins->dropPoisonGeneratingFlags();
2655 Mul = Builder.CreateFMulFMF(U->get(), Factor, Ins,
"factor.op.fmul");
2658 unsigned OpIdx = U->getOperandNo();
2659 auto *
LHS = OpIdx == 0 ?
Mul : Ins->getOperand(0);
2660 auto *
RHS = OpIdx == 1 ?
Mul : Ins->getOperand(1);
2663 Ins->getName() +
".reass", Ins->getIterator());
2665 NewBO->copyIRFlags(Ins);
2666 if (VariantOp == Ins)
2672 I.replaceAllUsesWith(VariantOp);
2692 if (!BO || !BO->isAssociative())
2696 bool LVInRHS = L.isLoopInvariant(BO->getOperand(0));
2698 if (!BO0 || BO0->getOpcode() != Opcode || !BO0->isAssociative() ||
2699 BO0->hasNUsesOrMore(BO0->getType()->isIntegerTy() ? 2 : 3))
2702 Value *LV = BO0->getOperand(0);
2703 Value *C1 = BO0->getOperand(1);
2704 Value *C2 = BO->getOperand(!LVInRHS);
2706 assert(BO->isCommutative() && BO0->isCommutative() &&
2707 "Associativity implies commutativity");
2708 if (L.isLoopInvariant(LV) && !L.isLoopInvariant(C1))
2710 if (L.isLoopInvariant(LV) || !L.isLoopInvariant(C1) || !L.isLoopInvariant(C2))
2713 auto *Preheader = L.getLoopPreheader();
2714 assert(Preheader &&
"Loop is not in simplify form?");
2717 auto *Inv = Builder.CreateBinOp(Opcode, C1, C2,
"invariant.op");
2720 Opcode, LV, Inv, BO->
getName() +
".reass", BO->getIterator());
2723 if (Opcode == Instruction::FAdd || Opcode == Instruction::FMul) {
2725 FastMathFlags Intersect = BO->getFastMathFlags() & BO0->getFastMathFlags();
2727 I->setFastMathFlags(Intersect);
2728 NewBO->setFastMathFlags(Intersect);
2732 Flags.AllKnownNonZero =
false;
2733 Flags.mergeFlags(*BO);
2734 Flags.mergeFlags(*BO0);
2738 Flags.applyFlags(*InvI);
2739 Flags.applyFlags(*NewBO);
2745 if (Opcode == Instruction::Add && Flags.HasNSW && !Flags.HasNUW &&
2749 InvI->setHasNoSignedWrap();
2750 NewBO->setHasNoSignedWrap();
2754 BO->replaceAllUsesWith(NewBO);
2759 if (BO0->use_empty()) {
2783 Value *LV, *C1, *C2;
2803 if (L.isLoopInvariant(LV) && !L.isLoopInvariant(C1))
2805 InvOp = Instruction::Sub;
2806 ResultOp = Instruction::Add;
2811 InvOp = Instruction::Add;
2812 ResultOp = Instruction::Sub;
2822 InvOp = Instruction::Sub;
2823 ResultOp = Instruction::Add;
2828 if (L.isLoopInvariant(LV) || !L.isLoopInvariant(C1) || !L.isLoopInvariant(C2))
2831 auto *Preheader = L.getLoopPreheader();
2832 assert(Preheader &&
"Loop is not in simplify form?");
2835 auto *Inv = Builder.CreateBinOp(InvOp, C1, C2,
"invariant.op");
2838 I.getName() +
".reass",
I.getIterator());
2844 I.replaceAllUsesWith(NewBO);
2867 if (
hoistGEP(
I, L, SafetyInfo, MSSAU, AC, DT)) {
2880 bool IsInt =
I.getType()->isIntOrIntVectorTy();
2884 ++NumIntAssociationsHoisted;
2886 ++NumFPAssociationsHoisted;
2892 ++NumBOAssociationsHoisted;
2898 ++NumBOAssociationsHoisted;
2909 assert(CurLoop->
contains(BB) &&
"Only valid if BB is IN the loop");
for(const MachineOperand &MO :llvm::drop_begin(OldMI.operands(), Desc.getNumOperands()))
assert(UImm &&(UImm !=~static_cast< T >(0)) &&"Invalid immediate!")
static msgpack::DocNode getNode(msgpack::DocNode DN, msgpack::Type Type, MCValue Val)
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
static GCRegistry::Add< ShadowStackGC > C("shadow-stack", "Very portable GC for uncooperative code generators")
This file contains the declarations for the subclasses of Constant, which represent the different fla...
DXIL Forward Handle Accesses
This file defines the DenseMap class.
early cse Early CSE w MemorySSA
This file provides various utilities for inspecting and working with the control flow graph in LLVM I...
Module.h This file contains the declarations for the Module class.
iv Induction Variable Users
static bool isReassociableOp(Instruction *I, unsigned IntOpcode, unsigned FPOpcode)
static bool isNotUsedOrFoldableInLoop(const Instruction &I, const Loop *CurLoop, const LoopSafetyInfo *SafetyInfo, TargetTransformInfo *TTI, bool &FoldableInLoop, bool LoopNestMode)
Return true if the only users of this instruction are outside of the loop.
static bool hoistGEP(Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
Reassociate gep (gep ptr, idx1), idx2 to gep (gep ptr, idx2), idx1 if this allows hoisting the inner ...
static void splitPredecessorsOfLoopExit(PHINode *PN, DominatorTree *DT, LoopInfo *LI, const Loop *CurLoop, LoopSafetyInfo *SafetyInfo, MemorySSAUpdater *MSSAU)
static bool isFoldableInLoop(const Instruction &I, const Loop *CurLoop, const TargetTransformInfo *TTI)
Return true if the instruction is foldable in the loop.
static bool hoistMinMax(Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU)
Try to simplify things like (A < INV_1 AND icmp A < INV_2) into (A < min(INV_1, INV_2)),...
static void moveInstructionBefore(Instruction &I, BasicBlock::iterator Dest, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, ScalarEvolution *SE)
static Instruction * cloneInstructionInExitBlock(Instruction &I, BasicBlock &ExitBlock, PHINode &PN, const LoopInfo *LI, const LoopSafetyInfo *SafetyInfo, MemorySSAUpdater &MSSAU)
static bool pointerInvalidatedByLoop(MemorySSA *MSSA, MemoryUse *MU, Loop *CurLoop, Instruction &I, SinkAndHoistLICMFlags &Flags, bool InvariantGroup)
static bool hoistSubAddAssociation(Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
Reassociate add/sub expressions of the form:
static bool hoistAdd(ICmpInst::Predicate Pred, Value *VariantLHS, Value *InvariantRHS, ICmpInst &ICmp, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
Try to turn things like "LV + C1 < C2" into "LV < C2 - C1".
static MemoryAccess * getClobberingMemoryAccess(MemorySSA &MSSA, BatchAAResults &BAA, SinkAndHoistLICMFlags &Flags, MemoryUseOrDef *MA)
static void hoist(Instruction &I, const DominatorTree *DT, const Loop *CurLoop, BasicBlock *Dest, ICFLoopSafetyInfo *SafetyInfo, MemorySSAUpdater &MSSAU, ScalarEvolution *SE, OptimizationRemarkEmitter *ORE)
When an instruction is found to only use loop invariant operands that is safe to hoist,...
static SmallVector< PointersAndHasReadsOutsideSet, 0 > collectPromotionCandidates(MemorySSA *MSSA, AliasAnalysis *AA, DominatorTree *DT, ICFLoopSafetyInfo *SafetyInfo, const SmallPtrSetImpl< const MDNode * > &LoopLocalAliasScopes, Loop *L)
static bool canSplitPredecessors(PHINode *PN, LoopSafetyInfo *SafetyInfo)
static bool sink(Instruction &I, LoopInfo *LI, DominatorTree *DT, const Loop *CurLoop, ICFLoopSafetyInfo *SafetyInfo, MemorySSAUpdater &MSSAU, OptimizationRemarkEmitter *ORE)
When an instruction is found to only be used outside of the loop, this function moves it to the exit ...
static bool isPotentiallyPromotable(const Instruction *I, const Loop *L)
Returns whether I is a memory access that may be a candidate for promotion out of the loop L.
static SmallPtrSet< const StoreInst *, 8 > collectStoresWithInvariantAATags(MemorySSA *MSSA, DominatorTree *DT, const SmallPtrSetImpl< const MDNode * > &LoopLocalAliasScopes, Loop *L)
Returns the potentially promotable stores with AA tags that are valid along all non-unwinding executi...
static bool hoistAddSub(Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
Reassociate and hoist add/sub expressions.
static bool isOnlyMemoryAccess(const Instruction *I, const Loop *L, const MemorySSAUpdater &MSSAU)
Return true if I is the only Instruction with a MemoryAccess in L.
static void foreachMemoryAccess(MemorySSA *MSSA, Loop *L, function_ref< void(Instruction *)> Fn)
static bool isLoadInvariantInLoop(LoadInst *LI, DominatorTree *DT, Loop *CurLoop)
static bool hoistInsertPastInsert(InsertElementInst *Ins, Loop *CurLoop, DominatorTree *DT, BasicBlock *HoistDest, ICFLoopSafetyInfo *SafetyInfo, MemorySSAUpdater &MSSAU, ScalarEvolution *SE, OptimizationRemarkEmitter *ORE)
static bool isHoistableAndSinkableInst(Instruction &I)
Return true if-and-only-if we know how to (mechanically) both hoist and sink a given instruction out ...
static Instruction * sinkThroughTriviallyReplaceablePHI(PHINode *TPN, Instruction *I, LoopInfo *LI, SmallDenseMap< BasicBlock *, Instruction *, 32 > &SunkCopies, const LoopSafetyInfo *SafetyInfo, const Loop *CurLoop, MemorySSAUpdater &MSSAU)
static bool hoistMulAddAssociation(const ScalarOptions &Opts, Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
Try to reassociate expressions like ((A1 * B1) + (A2 * B2) + ...) * C where A1, A2,...
static bool hasAnyMDOperandsFrom(const MDNode *N, const SmallPtrSetImpl< const MDNode * > &Operands)
Returns whether N has any operand from the set Operands.
static bool inSubLoop(BasicBlock *BB, Loop *CurLoop, LoopInfo *LI)
Little predicate that returns true if the specified basic block is in a subloop of the current one,...
static bool hoistSub(ICmpInst::Predicate Pred, Value *VariantLHS, Value *InvariantRHS, ICmpInst &ICmp, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
Try to reassociate and hoist the following two patterns: LV - C1 < C2 --> LV < C1 + C2,...
static void eraseInstruction(Instruction &I, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU)
static bool isSafeToExecuteUnconditionally(Instruction &Inst, const DominatorTree *DT, const TargetLibraryInfo *TLI, const Loop *CurLoop, const LoopSafetyInfo *SafetyInfo, OptimizationRemarkEmitter *ORE, const Instruction *CtxI, AssumptionCache *AC, bool AllowSpeculation)
Only sink or hoist an instruction if it is not a trapping instruction, or if the instruction is known...
static bool noConflictingReadWrites(Instruction *I, MemorySSA *MSSA, AAResults *AA, Loop *CurLoop, SinkAndHoistLICMFlags &Flags)
static bool hoistArithmetics(const ScalarOptions &Opts, Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
Aggregates various functions for hoisting computations out of loop.
static bool isTriviallyReplaceablePHI(const PHINode &PN, const Instruction &I)
Returns true if a PHINode is a trivially replaceable with an Instruction.
std::pair< SmallSetVector< Value *, 8 >, bool > PointersAndHasReadsOutsideSet
static std::optional< uint64_t > getConstantInsertionIndex(InsertElementInst *Ins)
static bool hoistBOAssociation(Instruction &I, Loop &L, ICFLoopSafetyInfo &SafetyInfo, MemorySSAUpdater &MSSAU, AssumptionCache *AC, DominatorTree *DT)
Reassociate associative binary expressions of the form.
static bool pointerInvalidatedByBlock(BasicBlock &BB, MemorySSA &MSSA, MemoryUse &MU)
This file defines the interface for the loop nest analysis.
This file provides utility analysis objects describing memory locations.
This file exposes an interface to building/using memory SSA to walk memory instructions using a use/d...
Contains a collection of routines for determining if a given instruction is guaranteed to execute if ...
uint64_t IntrinsicInst * II
PassInstrumentationCallbacks PIC
#define INITIALIZE_PASS_DEPENDENCY(depName)
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
#define INITIALIZE_PASS_BEGIN(passName, arg, name, cfg, analysis)
This file provides a priority worklist.
static DominatorTree getDomTree(Function &F)
Remove Loads Into Fake Uses
This file defines the 'Statistic' class, which is designed to be an easy way to expose various metric...
#define STATISTIC(VARNAME, DESC)
LLVM_ABI void addWithoutAATags(StoreInst *SI)
LLVM_ABI void add(const MemoryLocation &Loc)
These methods are used to add different types of instructions to the alias sets.
AnalysisUsage & addRequired()
AnalysisUsage & addPreserved()
Add the specified Pass class to the set of analyses preserved by this pass.
A cache of @llvm.assume calls within a function.
LLVM Basic Block Representation.
iterator begin()
Instruction iterator methods.
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.
LLVM_ABI InstListType::const_iterator getFirstNonPHIIt() const
Returns an iterator to the first instruction in this block that is not a PHINode instruction.
LLVM_ABI const DataLayout & getDataLayout() const
Get the data layout of the module this basic block belongs to.
InstListType::iterator iterator
Instruction iterators...
LLVM_ABI bool canSplitPredecessors() const
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction; assumes that the block is well-formed.
This class is a wrapper over an AAResults, and it is intended to be used only when there are no IR ch...
ModRefInfo getModRefInfo(const Instruction *I, const std::optional< MemoryLocation > &OptLoc)
static LLVM_ABI BinaryOperator * Create(BinaryOps Op, Value *S1, Value *S2, const Twine &Name=Twine(), InsertPosition InsertBefore=nullptr)
Construct a binary instruction, given the opcode and the two operands.
This class represents a function call, abstracting a target machine's calling convention.
static CallInst * Create(FunctionType *Ty, Value *F, const Twine &NameStr="", InsertPosition InsertBefore=nullptr)
void setPredicate(Predicate P)
Set the predicate for this instruction to the specified value.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
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,...
An abstraction over a floating-point predicate, and a pack of an integer predicate with samesign info...
static LLVM_ABI std::optional< CmpPredicate > getMatching(CmpPredicate A, CmpPredicate B)
Compares two CmpPredicates taking samesign into account and returns the canonicalized CmpPredicate if...
This is the shared class of boolean and integer constants.
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
A parsed version of the target data layout string in and methods for querying it.
TypeSize getTypeStoreSize(Type *Ty) const
Returns the maximum number of bytes that may be overwritten by storing the specified type.
static LLVM_ABI DebugLoc getMergedLocations(ArrayRef< DebugLoc > Locs)
Try to combine the vector of locations passed as input in a single one.
static DebugLoc getDropped()
std::pair< iterator, bool > try_emplace(KeyT &&Key, Ts &&...Args)
Analysis pass which computes a DominatorTree.
bool verify(VerificationLevel VL=VerificationLevel::Full) const
verify - checks if the tree is correct.
DomTreeNodeBase< NodeT > * getNode(const NodeT *BB) const
getNode - return the (Post)DominatorTree node for the specified basic block.
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 isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
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.
Convenience struct for specifying and reasoning about fast-math flags.
This implementation of LoopSafetyInfo use ImplicitControlFlowTracking to give precise answers on "may...
bool doesNotWriteMemoryBefore(const BasicBlock *BB) const
Returns true if we could not execute a memory-modifying instruction before we enter BB under assumpti...
bool isGuaranteedToExecute(const Instruction &Inst, const DominatorTree *DT) const override
Returns true if the instruction in a loop is guaranteed to execute at least once (under the assumptio...
void removeInstruction(const Instruction *Inst)
Inform safety info that we are planning to remove the instruction Inst from its block.
bool anyBlockMayThrow() const override
Returns true iff any block of the loop for which this info is contains an instruction that may throw ...
void insertInstructionTo(const Instruction *Inst, const BasicBlock *BB)
Inform the safety info that we are planning to insert a new instruction Inst into the basic block BB.
This instruction compares its operands according to the predicate given to the constructor.
static bool isGE(Predicate P)
Return true if the predicate is SGE or UGE.
static bool isLT(Predicate P)
Return true if the predicate is SLT or ULT.
static bool isGT(Predicate P)
Return true if the predicate is SGT or UGT.
bool isRelational() const
Return true if the predicate is relational (not EQ or NE).
static bool isLE(Predicate P)
Return true if the predicate is SLE or ULE.
This provides a uniform API for creating instructions and inserting them into a basic block: either a...
This instruction inserts a single (scalar) element into a VectorType value.
VectorType * getType() const
Overload to return most specific vector type.
LLVM_ABI void mergeDIAssignID(ArrayRef< const Instruction * > SourceInstructions)
Merge the DIAssignID metadata from this instruction and those attached to instructions in SourceInstr...
LLVM_ABI void setAAMetadata(const AAMDNodes &N)
Sets the AA metadata on this instruction from the AAMDNodes structure.
user_iterator_impl< Instruction > user_iterator
Specialize the methods defined in Value, as we know that an instruction can only be used by other ins...
bool hasMetadata() const
Return true if this instruction has any metadata attached to it.
LLVM_ABI void moveBefore(InstListType::iterator InsertPos)
Unlink this instruction from its current basic block and insert it into the basic block that MovePos ...
LLVM_ABI bool isAtomic() const LLVM_READONLY
Return true if this instruction has an AtomicOrdering of unordered or higher.
LLVM_ABI void insertBefore(InstListType::iterator InsertPos)
Insert an unlinked instruction into a basic block immediately before the specified position.
Instruction * user_back()
LLVM_ABI const Function * getFunction() const
Return the function this instruction belongs to.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
LLVM_ABI void setMetadata(unsigned KindID, MDNode *Node)
Set the metadata of the specified kind to the specified node.
LLVM_ABI AAMDNodes getAAMetadata() const
Returns the AA metadata for this instruction.
LLVM_ABI void dropPoisonGeneratingFlags()
Drops flags that may cause this instruction to evaluate to poison despite having non-poison inputs.
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.
A wrapper class for inspecting calls to intrinsic functions.
LLVM_ABI void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
LLVM_ABI PreservedAnalyses run(Loop &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U)
LLVM_ABI PreservedAnalyses run(LoopNest &L, LoopAnalysisManager &AM, LoopStandardAnalysisResults &AR, LPMUpdater &U)
LLVM_ABI void printPipeline(raw_ostream &OS, function_ref< StringRef(StringRef)> MapClassName2PassName)
This class provides an interface for updating the loop pass manager based on mutations to the loop ne...
static void getLazyBFIAnalysisUsage(AnalysisUsage &AU)
Helper for client passes to set up the analysis usage on behalf of this pass.
An instruction for reading from memory.
void setAlignment(Align Align)
Value * getPointerOperand()
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this load instruction.
Analysis pass that exposes the LoopInfo for a function.
bool contains(const LoopT *L) const
Return true if the specified loop is contained within this loop.
BlockT * getHeader() const
BlockT * getLoopPreheader() const
If there is a preheader for this loop, return it.
ArrayRef< BlockT * > getBlocks() const
Get a list of the basic blocks which make up this loop.
void getUniqueExitBlocks(SmallVectorImpl< BlockT * > &ExitBlocks) const
Return all unique successor blocks of this loop.
Wrapper class to LoopBlocksDFS that provides a standard begin()/end() interface for the DFS reverse p...
void perform(const LoopInfo *LI)
Traverse the loop blocks and store the DFS result.
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
LLVM_ABI bool wouldBeOutOfLoopUseRequiringLCSSA(const Value *V, const BasicBlock *ExitBB) const
This class represents a loop nest and can be used to query its properties.
Function * getParent() const
Return the function to which the loop-nest belongs.
Loop & getOutermostLoop() const
Return the outermost loop in the loop nest.
Captures loop safety information.
LLVM_ABI void copyColors(BasicBlock *New, BasicBlock *Old)
Copy colors of block Old into the block New.
LLVM_ABI const DenseMap< BasicBlock *, ColorVector > & getBlockColors() const
Returns block colors map that is used to update funclet operand bundles.
virtual bool isGuaranteedToExecute(const Instruction &Inst, const DominatorTree *DT) const =0
Returns true if the instruction in a loop is guaranteed to execute at least once (under the assumptio...
Represents a single loop in the control flow graph.
bool hasLoopInvariantOperands(const Instruction *I) const
Return true if all the operands of the specified instruction are loop invariant.
bool isLoopInvariant(const Value *V) const
Return true if the specified value is loop invariant.
Tracking metadata reference owned by Metadata.
BasicBlock * getBlock() const
bool onlyWritesMemory() const
Whether this function only (at most) writes memory.
bool doesNotAccessMemory() const
Whether this function accesses no memory.
bool onlyReadsMemory() const
Whether this function only (at most) reads memory.
Representation for a specific memory location.
static LLVM_ABI MemoryLocation get(const LoadInst *LI)
Return a location with information about the memory reference by the given instruction.
An analysis that produces MemorySSA for a function.
MemorySSA * getMemorySSA() const
Get handle on MemorySSA.
LLVM_ABI void insertDef(MemoryDef *Def, bool RenameUses=false)
Insert a definition into the MemorySSA IR.
LLVM_ABI void insertUse(MemoryUse *Use, bool RenameUses=false)
LLVM_ABI MemoryAccess * createMemoryAccessInBB(Instruction *I, MemoryAccess *Definition, const BasicBlock *BB, MemorySSA::InsertionPlace Point, bool CreationMustSucceed=true)
Create a MemoryAccess in MemorySSA at a specified point in a block.
LLVM_ABI void removeMemoryAccess(MemoryAccess *, bool OptimizePhis=false)
Remove a MemoryAccess from MemorySSA, including updating all definitions and uses.
LLVM_ABI MemoryUseOrDef * createMemoryAccessAfter(Instruction *I, MemoryAccess *Definition, MemoryAccess *InsertPt)
Create a MemoryAccess in MemorySSA after an existing MemoryAccess.
LLVM_ABI void moveToPlace(MemoryUseOrDef *What, BasicBlock *BB, MemorySSA::InsertionPlace Where)
MemoryAccess * getClobberingMemoryAccess(const Instruction *I, BatchAAResults &AA)
Given a memory Mod/Ref/ModRef'ing instruction, calling this will give you the nearest dominating Memo...
Legacy analysis pass which computes MemorySSA.
Encapsulates MemorySSA, including all data associated with memory accesses.
DefsList * getBlockDefs(const BasicBlock *BB) const
Return the list of MemoryDef's and MemoryPhi's for a given basic block.
LLVM_ABI MemorySSAWalker * getSkipSelfWalker()
AccessList * getBlockAccesses(const BasicBlock *BB) const
Return the list of MemoryAccess's for a given basic block.
LLVM_ABI bool dominates(const MemoryAccess *A, const MemoryAccess *B) const
Given two memory accesses in potentially different blocks, determine whether MemoryAccess A dominates...
LLVM_ABI void verifyMemorySSA(VerificationLevel=VerificationLevel::Fast) const
Verify that MemorySSA is self consistent (IE definitions dominate all uses, uses appear in the right ...
MemoryUseOrDef * getMemoryAccess(const Instruction *I) const
Given a memory Mod/Ref'ing instruction, get the MemorySSA access associated with it.
LLVM_ABI bool locallyDominates(const MemoryAccess *A, const MemoryAccess *B) const
Given two memory accesses in the same basic block, determine whether MemoryAccess A dominates MemoryA...
bool isLiveOnEntryDef(const MemoryAccess *MA) const
Return true if MA represents the live on entry value.
Class that has the common methods + fields of memory uses/defs.
MemoryAccess * getDefiningAccess() const
Get the access that produces the memory state used by this Use.
Represents read-only accesses to memory.
A Module instance is used to store all the information related to an LLVM module.
void addIncoming(Value *V, BasicBlock *BB)
Add an incoming value to the end of the PHI list.
op_range incoming_values()
BasicBlock * getIncomingBlock(unsigned i) const
Return incoming basic block number i.
int getBasicBlockIndex(const BasicBlock *BB) const
Return the first index of the specified basic block in the value list for this PHI.
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 PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
Pass interface - Implemented by all 'passes'.
PointerIntPair - This class implements a pair of a pointer and small integer.
void setInt(IntType IntVal) &
PointerTy getPointer() const
static LLVM_ABI PoisonValue * get(Type *T)
Static factory methods - Return an 'poison' object of the specified type.
PredIteratorCache - This class is an extremely trivial cache for predecessor iterator queries.
size_t size(BasicBlock *BB)
ArrayRef< BasicBlock * > get(BasicBlock *BB)
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.
bool empty() const
Determine if the PriorityWorklist is empty or not.
bool insert(const T &X)
Insert a new element into the PriorityWorklist.
Helper class for SSA formation on a set of values defined in multiple blocks.
The main scalar evolution driver.
LLVM_ABI void forgetBlockAndLoopDispositions(Value *V=nullptr)
Called when the client has changed the disposition of values in a loop or block.
LLVM_ABI void forgetLoopDispositions()
Called when the client has changed the disposition of values in this loop.
bool remove(const value_type &X)
Remove an item from the set vector.
bool empty() const
Determine if the SetVector is empty or not.
iterator begin()
Get an iterator to the beginning of the SetVector.
bool insert(const value_type &X)
Insert a new element into the SetVector.
Flags controlling how much is checked when sinking or hoisting instructions.
LLVM_ABI SinkAndHoistLICMFlags(unsigned LicmMssaOptCap, unsigned LicmMssaNoAccForPromotionCap, bool IsSink, Loop &L, MemorySSA &MSSA)
unsigned LicmMssaNoAccForPromotionCap
A version of PriorityWorklist that selects small size optimized data structures for the vector and ma...
A templated base class for SmallPtrSet which provides the typesafe interface that is common across al...
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
void insert_range(Range &&R)
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.
bool contains(ConstPtrType Ptr) const
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
A SetVector that performs no allocations if smaller than a certain size.
This class consists of common code factored out of the SmallVector class to reduce code duplication b...
reference emplace_back(ArgTypes &&... Args)
void reserve(size_type N)
void push_back(const T &Elt)
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
An instruction for storing to memory.
void setAlignment(Align Align)
void setOrdering(AtomicOrdering Ordering)
Sets the ordering constraint of this store instruction.
static unsigned getPointerOperandIndex()
Represent a constant reference to a string, i.e.
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.
A Use represents the edge between a Value definition and its users.
const Use & getOperandUse(unsigned i) const
void setOperand(unsigned i, Value *Val)
Value * getOperand(unsigned i) const
unsigned getNumOperands() const
LLVM Value Representation.
Type * getType() const
All values are typed, get the type of this value.
LLVM_ABI bool hasOneUser() const
Return true if there is exactly one user of this value.
LLVM_ABI std::string getNameOrAsOperand() const
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.
iterator_range< user_iterator > users()
iterator_range< use_iterator > uses()
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.
constexpr ScalarTy getFixedValue() const
constexpr bool isScalable() const
Returns whether the quantity is scaled by a runtime quantity (vscale).
An efficient, type-erasing, non-owning reference to a callable.
const ParentTy * getParent() const
self_iterator getIterator()
This class implements an extremely fast bulk output stream that can only output to a stream.
Abstract Attribute helper functions.
constexpr char Align[]
Key for Kernel::Arg::Metadata::mAlign.
@ BasicBlock
Various leaf nodes.
OneUse_match< SubPat > m_OneUse(const SubPat &SP)
BinaryOp_match< LHS, RHS, Instruction::Add > m_Add(const LHS &L, const RHS &R)
OverflowingBinaryOp_match< LHS, RHS, Instruction::Sub, OverflowingBinaryOperator::NoSignedWrap > m_NSWSub(const LHS &L, const RHS &R)
bool match(Val *V, const Pattern &P)
match_bind< Instruction > m_Instruction(Instruction *&I)
Match an instruction, capturing it if we match.
auto m_Value()
Match an arbitrary value and ignore it.
auto m_LogicalOr()
Matches L || R where L and R are arbitrary values.
BinaryOp_match< LHS, RHS, Instruction::Add, true > m_c_Add(const LHS &L, const RHS &R)
Matches a Add with LHS and RHS in either order.
auto m_Intrinsic(const Ts &...Ops)
Match intrinsic calls like this: m_Intrinsic<Intrinsic::fabs>(m_Value(X))
OverflowingBinaryOp_match< LHS, RHS, Instruction::Sub, OverflowingBinaryOperator::NoUnsignedWrap > m_NUWSub(const LHS &L, const RHS &R)
match_combine_or< OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoSignedWrap >, DisjointOr_match< LHS, RHS > > m_NSWAddLike(const LHS &L, const RHS &R)
Match either "add nsw" or "or disjoint".
CmpClass_match< LHS, RHS, ICmpInst > m_ICmp(CmpPredicate &Pred, const LHS &L, const RHS &R)
auto m_LogicalAnd()
Matches L && R where L and R are arbitrary values.
match_combine_or< OverflowingBinaryOp_match< LHS, RHS, Instruction::Add, OverflowingBinaryOperator::NoUnsignedWrap >, DisjointOr_match< LHS, RHS > > m_NUWAddLike(const LHS &L, const RHS &R)
Match either "add nuw" or "or disjoint".
BinaryOp_match< LHS, RHS, Instruction::Sub > m_Sub(const LHS &L, const RHS &R)
DiagnosticInfoOptimizationBase::Argument NV
friend class Instruction
Iterator for Instructions in a `BasicBlock.
This is an optimization pass for GlobalISel generic memory operations.
@ NeverOverflows
Never overflows.
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 canSinkOrHoistInst(Instruction &I, AAResults *AA, DominatorTree *DT, Loop *CurLoop, MemorySSAUpdater &MSSAU, bool TargetExecutesOncePerLoop, SinkAndHoistLICMFlags &LICMFlags, OptimizationRemarkEmitter *ORE=nullptr)
Returns true if is legal to hoist or sink this instruction disregarding the possible introduction of ...
LLVM_ABI unsigned getLicmMssaNoAccForPromotionCap(const cl::LibraryOptionsContext *LibraryOptions)
Returns -licm-mssa-max-acc-promotion of LibraryOptions, or its global value if null.
auto pred_end(const MachineBasicBlock *BB)
decltype(auto) dyn_cast(const From &Val)
dyn_cast<X> - Return the argument parameter cast to the specified type.
bool isStrongerThanMonotonic(AtomicOrdering AO)
LLVM_ABI void salvageDebugInfo(const MachineRegisterInfo &MRI, MachineInstr &MI)
Assuming the instruction MI is going to be deleted, attempt to salvage debug users of MI by writing t...
@ Load
The value being inserted comes from a load (InsertElement only).
@ Store
The extracted value is stored (ExtractElement only).
constexpr from_range_t from_range
LLVM_ABI bool formLCSSARecursively(Loop &L, const DominatorTree &DT, const LoopInfo *LI, ScalarEvolution *SE)
Put a loop nest into LCSSA form.
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...
auto cast_or_null(const Y &Val)
MemoryEffectsBase< IRMemLocation > MemoryEffects
Summary of how a function affects memory in the program.
const ScalarOptions & getScalarOptions(const LLVMContext &C)
LLVM_ABI bool isSafeToSpeculativelyExecute(const Instruction *I, const Instruction *CtxI=nullptr, AssumptionCache *AC=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr, bool UseVariableInfo=true, bool IgnoreUBImplyingAttrs=true)
Return true if the instruction does not have any effects besides calculating the result and does not ...
LLVM_ABI bool PointerMayBeCapturedBefore(const Value *V, bool ReturnCaptures, const Instruction *I, const DominatorTree *DT, bool IncludeI=false, unsigned MaxUsesToExplore=0, const LoopInfo *LI=nullptr)
PointerMayBeCapturedBefore - Return true if this pointer value may be captured by the enclosing funct...
LLVM_ABI Pass * createLICMPass()
LLVM_ABI SmallVector< BasicBlock *, 16 > collectChildrenInLoop(DominatorTree *DT, DomTreeNode *N, const Loop *CurLoop)
Does a BFS from a given node to all of its children inside a given loop.
RelativeUniformCounterPtr ValuesPtrExpr VTableAddr Value
DomTreeNodeBase< BasicBlock > DomTreeNode
AnalysisManager< Loop, LoopStandardAnalysisResults & > LoopAnalysisManager
The loop analysis manager.
LLVM_ABI bool hoistRegion(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *, AssumptionCache *, TargetLibraryInfo *, Loop *, MemorySSAUpdater &, ScalarEvolution *, ICFLoopSafetyInfo *, SinkAndHoistLICMFlags &, OptimizationRemarkEmitter *, bool, bool AllowSpeculation)
Walk the specified region of the CFG (defined by all blocks dominated by the specified block,...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI bool isInstructionTriviallyDead(Instruction *I, const TargetLibraryInfo *TLI=nullptr)
Return true if the result produced by the instruction is not used, and the instruction will return.
LLVM_ABI unsigned getLicmMssaOptCap(const cl::LibraryOptionsContext *LibraryOptions)
Returns -licm-mssa-optimization-cap of LibraryOptions, or its global value if null.
LLVM_ABI bool isGuard(const User *U)
Returns true iff U has semantics of a guard expressed in a form of call of llvm.experimental....
auto reverse(ContainerTy &&C)
LLVM_ABI OverflowResult computeOverflowForSignedSub(const Value *LHS, const Value *RHS, const SimplifyQuery &SQ)
LLVM_ABI void initializeLegacyLICMPassPass(PassRegistry &)
bool isModSet(const ModRefInfo MRI)
LLVM_ABI raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
LLVM_TEMPLATE_ABI void appendLoopsToWorklist(RangeT &&, SmallPriorityWorklist< Loop *, 4 > &)
Utility that implements appending of loops onto a worklist given a range.
LLVM_ABI bool isNotVisibleOnUnwind(const Value *Object, bool &RequiresNoCaptureBeforeUnwind)
Return true if Object memory is not visible after an unwind, in the sense that program semantics cann...
LLVM_ABI const Value * getUnderlyingObject(const Value *V, unsigned MaxLookup=MaxLookupSearchDepth, bool MustPreserveProvenance=false)
This method strips off any GEP address adjustments, pointer casts or llvm.threadlocal....
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 void getLoopAnalysisUsage(AnalysisUsage &AU)
Helper to consistently add the set of standard passes to a loop pass's AnalysisUsage.
LLVM_ABI BasicBlock * SplitBlockPredecessors(BasicBlock *BB, ArrayRef< BasicBlock * > Preds, const char *Suffix, DominatorTree *DT, LoopInfo *LI=nullptr, MemorySSAUpdater *MSSAU=nullptr, bool PreserveLCSSA=false)
This method introduces at least one new basic block into the function and moves some of the predecess...
ModRefInfo
Flags indicating whether a memory access modifies or references memory.
LLVM_ABI bool VerifyMemorySSA
Enables verification of MemorySSA.
LLVM_ABI bool salvageKnowledge(Instruction *I, AssumptionCache *AC=nullptr, DominatorTree *DT=nullptr)
Calls BuildAssumeFromInst and if the resulting llvm.assume is valid insert if before I.
LLVM_ABI bool hasDisableLICMTransformsHint(const Loop *L)
Look for the loop attribute that disables the LICM transformation heuristics.
LLVM_ABI OverflowResult computeOverflowForSignedAdd(const WithCache< const Value * > &LHS, const WithCache< const Value * > &RHS, const SimplifyQuery &SQ)
DWARFExpression::Operation Op
LLVM_ABI bool isDereferenceableAndAlignedPointer(const Value *V, Type *Ty, Align Alignment, const SimplifyQuery &Q, bool IgnoreFree=false)
Returns true if V is always a dereferenceable pointer with alignment greater or equal than requested.
ArrayRef(const T &OneElt) -> ArrayRef< T >
LLVM_ABI bool isIdentifiedFunctionLocal(const Value *V)
Return true if V is umabigously identified at the function-level.
OutputIt move(R &&Range, OutputIt Out)
Provide wrappers to std::move which take ranges instead of having to pass begin/end explicitly.
LLVM_ABI OverflowResult computeOverflowForUnsignedSub(const Value *LHS, const Value *RHS, const SimplifyQuery &SQ)
TinyPtrVector< BasicBlock * > ColorVector
auto pred_begin(const MachineBasicBlock *BB)
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.
void erase_if(Container &C, UnaryPredicate P)
Provide a container algorithm similar to C++ Library Fundamentals v2's erase_if which is equivalent t...
auto predecessors(const MachineBasicBlock *BB)
Type * getLoadStoreType(const Value *I)
A helper function that returns the type of a load or store instruction.
LLVM_ABI bool sinkRegion(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *, TargetLibraryInfo *, TargetTransformInfo *, Loop *CurLoop, MemorySSAUpdater &, ICFLoopSafetyInfo *, SinkAndHoistLICMFlags &, OptimizationRemarkEmitter *, Loop *OutermostLoop=nullptr)
Walk the specified region of the CFG (defined by all blocks dominated by the specified block,...
LLVM_ABI OverflowResult computeOverflowForUnsignedAdd(const WithCache< const Value * > &LHS, const WithCache< const Value * > &RHS, const SimplifyQuery &SQ)
LLVM_ABI bool canHoistLoad(LoadInst &LI, AAResults *AA, DominatorTree *DT, Loop *CurLoop, MemorySSA &MSSA, bool TargetExecutesOncePerLoop, SinkAndHoistLICMFlags &LICMFlags, OptimizationRemarkEmitter *ORE=nullptr)
Returns true if it is legal to hoist LI out of CurLoop.
LLVM_ABI bool isDereferenceablePointer(const Value *V, Type *Ty, const SimplifyQuery &Q, bool IgnoreFree=false)
Equivalent to isDereferenceableAndAlignedPointer with an alignment of 1.
AAResults AliasAnalysis
Temporary typedef for legacy code that uses a generic AliasAnalysis pointer or reference.
bool capturesNothing(CaptureComponents CC)
LLVM_ABI bool isKnownNonNegative(const Value *V, const SimplifyQuery &SQ, unsigned Depth=0)
Returns true if the give value is known to be non-negative.
LLVM_ABI bool promoteLoopAccessesToScalars(const SmallSetVector< Value *, 8 > &, SmallVectorImpl< BasicBlock * > &, SmallVectorImpl< BasicBlock::iterator > &, SmallVectorImpl< MemoryAccess * > &, PredIteratorCache &, LoopInfo *, DominatorTree *, AssumptionCache *AC, const TargetLibraryInfo *, TargetTransformInfo *, Loop *, MemorySSAUpdater &, ICFLoopSafetyInfo *, OptimizationRemarkEmitter *, bool AllowSpeculation, bool HasReadsOutsideSet)
Try to promote memory values to scalars by sinking stores out of the loop and moving loads to before ...
bool isNoModRef(const ModRefInfo MRI)
LLVM_ABI bool sinkRegionForLoopNest(DomTreeNode *, AAResults *, LoopInfo *, DominatorTree *, TargetLibraryInfo *, TargetTransformInfo *, Loop *, MemorySSAUpdater &, ICFLoopSafetyInfo *, SinkAndHoistLICMFlags &, OptimizationRemarkEmitter *)
Call sinkRegion on loops contained within the specified loop in order from innermost to outermost.
bool isRefSet(const ModRefInfo MRI)
LLVM_ABI bool isWritableObject(const Value *Object, bool &ExplicitlyDereferenceableOnly)
Return true if the Object is writable, in the sense that any location based on this pointer that can ...
LLVM_ABI void reportFatalUsageError(Error Err)
Report a fatal error that does not indicate a bug in LLVM.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
A collection of metadata nodes that might be associated with a memory access used by the alias-analys...
LLVM_ABI AAMDNodes merge(const AAMDNodes &Other) const
Given two sets of AAMDNodes applying to potentially different locations, determine the best AAMDNodes...
This struct is a compact representation of a valid (non-zero power of two) alignment.
The adaptor from a function pass to a loop pass computes these analyses and makes them available to t...
TargetTransformInfo & TTI
A lightweight accessor for an operand bundle meant to be passed around by value.
uint32_t getTagID() const
Return the tag of this operand bundle as an integer.