Go to the documentation of this file.
27 #include "llvm/Config/llvm-config.h"
47 #ifdef EXPENSIVE_CHECKS
67 return all_of(
I->operands(), [
this](
Value *V) { return isLoopInvariant(V); });
85 if (
I->mayReadFromMemory())
99 for (
Value *Operand :
I->operands())
104 I->moveBefore(InsertPt);
114 I->dropUnknownNonDebugMetadata();
142 assert(Incoming && Backedge &&
"expected non-null incoming and backedges");
149 BasicBlock *Incoming =
nullptr, *Backedge =
nullptr;
162 if (
ConstantInt *CI = dyn_cast<ConstantInt>(Inc->getOperand(1)))
172 if (
BranchInst *BI = dyn_cast_or_null<BranchInst>(Latch->getTerminator()))
173 if (BI->isConditional())
174 return dyn_cast<ICmpInst>(BI->getCondition());
188 if (Op0 == &IndVar || Op0 == &StepInst)
191 if (Op1 == &IndVar || Op1 == &StepInst)
206 if (!InitialIVValue || !StepInst)
212 Value *StepValue =
nullptr;
213 if (SE.
getSCEV(StepInstOp1) == Step)
214 StepValue = StepInstOp1;
215 else if (SE.
getSCEV(StepInstOp0) == Step)
216 StepValue = StepInstOp0;
222 return LoopBounds(L, *InitialIVValue, *StepInst, StepValue, *FinalIVValue,
230 assert(Latch &&
"Expecting valid latch");
237 "Expecting the latch compare instruction to be a CmpInst");
245 if (LatchCmpInst->
getOperand(0) == &getFinalIVValue())
250 if (LatchCmpInst->
getOperand(0) == &getStepInst() ||
251 LatchCmpInst->
getOperand(1) == &getStepInst())
259 if (
D == Direction::Increasing)
262 if (
D == Direction::Decreasing)
272 dyn_cast<SCEVAddRecExpr>(SE.getSCEV(&getStepInst())))
273 if (
const SCEV *StepRecur = StepAddRecExpr->getStepRecurrence(SE)) {
274 if (SE.isKnownPositive(StepRecur))
275 return Direction::Increasing;
276 if (SE.isKnownNegative(StepRecur))
277 return Direction::Decreasing;
295 assert(Header &&
"Expected a valid loop header");
309 Value *StepInst = IndVar.getIncomingValueForBlock(Latch);
315 if (StepInst == LatchCmpOp0 || StepInst == LatchCmpOp1)
322 if (&IndVar == LatchCmpOp0 || &IndVar == LatchCmpOp1)
369 "Expecting a loop with valid preheader and latch");
420 if (!Step || !Step->
isOne())
433 if (
I.getType()->isTokenTy())
436 for (
const Use &U :
I.uses()) {
437 const Instruction *UI = cast<Instruction>(U.getUser());
443 if (
const PHINode *
P = dyn_cast<PHINode>(UI))
444 UserBB =
P->getIncomingBlock(U);
488 if (isa<IndirectBrInst>(
BB->getTerminator()) ||
489 isa<CallBrInst>(
BB->getTerminator()))
493 if (
auto *CB = dyn_cast<CallBase>(&
I))
494 if (CB->cannotDuplicate())
515 else if (MD != LoopID)
526 "Loop ID needs at least one operand");
528 "Loop ID should refer to itself");
533 BB->getTerminator()->setMetadata(LLVMContext::MD_loop, LoopID);
543 Context, LoopID, {
"llvm.loop.unroll."}, {DisableUnrollMD});
566 if (!DesiredLoopIdMetadata)
569 MDNode *ParallelAccesses =
572 ParallelAccessGroups;
573 if (ParallelAccesses) {
575 MDNode *AccGroup = cast<MDNode>(MD.get());
577 "List item must be an access group");
578 ParallelAccessGroups.
insert(AccGroup);
589 if (!
I.mayReadOrWriteMemory())
592 if (
MDNode *AccessGroup =
I.getMetadata(LLVMContext::MD_access_group)) {
593 auto ContainsAccessGroup = [&ParallelAccessGroups](
MDNode *AG) ->
bool {
594 if (AG->getNumOperands() == 0) {
596 return ParallelAccessGroups.
count(AG);
599 for (
const MDOperand &AccessListItem : AG->operands()) {
600 MDNode *AccGroup = cast<MDNode>(AccessListItem.get());
602 "List item must be an access group");
603 if (ParallelAccessGroups.
count(AccGroup))
609 if (ContainsAccessGroup(AccessGroup))
618 I.getMetadata(LLVMContext::MD_mem_parallel_loop_access);
639 for (
unsigned i = 1, ie = LoopID->getNumOperands();
i < ie; ++
i) {
640 if (
DILocation *L = dyn_cast<DILocation>(LoopID->getOperand(
i))) {
654 if (
DebugLoc DL = PHeadBB->getTerminator()->getDebugLoc())
660 return LocRange(HeadBB->getTerminator()->getDebugLoc());
665 #if !defined(NDEBUG) || defined(LLVM_ENABLE_DUMP)
680 class UnloopUpdater {
694 bool FoundIB =
false;
697 UnloopUpdater(
Loop *UL,
LoopInfo *LInfo) : Unloop(*UL), LI(LInfo), DFS(UL) {}
699 void updateBlockParents();
701 void removeBlocksFromAncestors();
703 void updateSubloopParents();
712 void UnloopUpdater::updateBlockParents() {
713 if (Unloop.getNumBlocks()) {
719 Loop *L = LI->getLoopFor(POI);
720 Loop *
NL = getNearestLoop(POI, L);
724 assert((
NL != &Unloop && (!
NL ||
NL->contains(&Unloop))) &&
725 "uninitialized successor");
726 LI->changeLoopFor(POI,
NL);
730 assert((FoundIB || Unloop.contains(L)) &&
"uninitialized successor");
736 bool Changed = FoundIB;
737 for (
unsigned NIters = 0; Changed; ++NIters) {
738 assert(NIters < Unloop.getNumBlocks() &&
"runaway iterative algorithm");
745 POE = DFS.endPostorder();
748 Loop *L = LI->getLoopFor(*POI);
749 Loop *
NL = getNearestLoop(*POI, L);
751 assert(
NL != &Unloop && (!
NL ||
NL->contains(&Unloop)) &&
752 "uninitialized successor");
753 LI->changeLoopFor(*POI,
NL);
761 void UnloopUpdater::removeBlocksFromAncestors() {
765 Loop *OuterParent = LI->getLoopFor(
BB);
766 if (Unloop.contains(OuterParent)) {
769 OuterParent = SubloopParents[OuterParent];
775 assert(OldParent &&
"new loop is not an ancestor of the original");
776 OldParent->removeBlockFromLoop(
BB);
782 void UnloopUpdater::updateSubloopParents() {
783 while (!Unloop.isInnermost()) {
784 Loop *Subloop = *std::prev(Unloop.end());
785 Unloop.removeChildLoop(std::prev(Unloop.end()));
787 assert(SubloopParents.count(Subloop) &&
"DFS failed to visit subloop");
788 if (
Loop *Parent = SubloopParents[Subloop])
789 Parent->addChildLoop(Subloop);
791 LI->addTopLevelLoop(Subloop);
804 Loop *NearLoop = BBLoop;
806 Loop *Subloop =
nullptr;
807 if (NearLoop != &Unloop && Unloop.contains(NearLoop)) {
812 assert(Subloop &&
"subloop is not an ancestor of the original loop");
815 NearLoop = SubloopParents.insert({Subloop, &Unloop}).first->second;
820 assert(!Subloop &&
"subloop blocks must have a successor");
823 for (;
I !=
E; ++
I) {
827 Loop *L = LI->getLoopFor(*
I);
831 assert((FoundIB || !DFS.hasPostorder(*
I)) &&
"should have seen IB");
834 if (L != &Unloop && Unloop.contains(L)) {
843 L = SubloopParents[L];
854 if (NearLoop == &Unloop || !NearLoop || NearLoop->
contains(L))
858 SubloopParents[Subloop] = NearLoop;
885 if (getLoopFor(
BB) != Unloop)
890 changeLoopFor(
BB,
nullptr);
911 UnloopUpdater Updater(Unloop,
this);
912 Updater.updateBlockParents();
915 Updater.removeBlocksFromAncestors();
918 Updater.updateSubloopParents();
923 assert(
I != ParentLoop->
end() &&
"Couldn't find loop");
942 const Loop *L = getLoopFor(
I->getParent());
980 OS << Banner <<
" (loop: ";
993 OS <<
"\n; Preheader:";
994 PreHeader->print(OS);
998 for (
auto *Block : L.
blocks())
1002 OS <<
"Printing <null> block";
1006 if (!ExitBlocks.empty()) {
1007 OS <<
"\n; Exit blocks";
1008 for (
auto *Block : ExitBlocks)
1012 OS <<
"Printing <null> block";
1034 if (
Name.equals(
S->getString()))
1077 mdconst::extract_or_null<ConstantInt>(MD->
getOperand(1).
get()))
1078 return IntMD->getZExtValue();
1095 ConstantInt *IntMD = mdconst::extract_or_null<ConstantInt>(AttrMD->get());
1122 return Node->getNumOperands() == 0 && Node->isDistinct();
1133 MDs.push_back(
nullptr);
1139 bool IsVectorMetadata =
false;
1141 if (
MDNode *MD = dyn_cast<MDNode>(
Op)) {
1142 const MDString *
S = dyn_cast<MDString>(MD->getOperand(0));
1149 if (!IsVectorMetadata)
1181 LI.analyze(getAnalysis<DominatorTreeWrapperPass>().getDomTree());
1192 auto &DT = getAnalysis<DominatorTreeWrapperPass>().getDomTree();
1224 POE = Traversal.
end();
A set of analyses that are preserved following a run of a transformation pass.
void initializeLoopInfoWrapperPassPass(PassRegistry &)
Traverse the blocks in a loop using a depth-first search.
bool isLoopInvariant(const Value *V) const
Return true if the specified value is loop invariant.
Predicate getSwappedPredicate() const
For example, EQ->EQ, SLE->SGE, ULT->UGT, OEQ->OEQ, ULE->UGE, OLT->OGT, etc.
#define LLVM_DUMP_METHOD
Mark debug helper function definitions like dump() that should not be stripped from debug builds.
This is an optimization pass for GlobalISel generic memory operations.
ICmpInst * getLatchCmpInst() const
Get the latch condition instruction.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
BasicBlock * getUniqueExitBlock() const
If getUniqueExitBlocks would return exactly one block, return that block.
void getExitBlocks(SmallVectorImpl< BlockT * > &ExitBlocks) const
Return all of the successor blocks of this loop.
auto drop_begin(T &&RangeOrContainer, size_t N=1)
Return a range covering RangeOrContainer with the first N elements excluded.
Predicate
This enumeration lists the possible predicates for CmpInst subclasses.
InstListType::iterator iterator
Instruction iterators...
bool isSafeToSpeculativelyExecute(const Value *V, const Instruction *CtxI=nullptr, const DominatorTree *DT=nullptr, const TargetLibraryInfo *TLI=nullptr)
Return true if the instruction does not have any effects besides calculating the result and does not ...
const Function * getParent() const
Return the enclosing method, or null if none.
PassT::Result & getResult(IRUnitT &IR, ExtraArgTs... ExtraArgs)
Get the result of an analysis pass for a given IR unit.
Interval::succ_iterator succ_end(Interval *I)
LocationClass< Ty > location(Ty &L)
Represents a single loop in the control flow graph.
This currently compiles esp xmm0 movsd esp eax eax esp ret We should use not the dag combiner This is because dagcombine2 needs to be able to see through the X86ISD::Wrapper which DAGCombine can t really do The code for turning x load into a single vector load is target independent and should be moved to the dag combiner The code for turning x load into a vector load can only handle a direct load from a global or a direct load from the stack It should be generalized to handle any load from P
bool contains(const Loop *L) const
Return true if the specified loop is contained within in this loop.
bool invalidate(Function &F, const PreservedAnalyses &PA, FunctionAnalysisManager::Invalidator &)
Handle invalidation explicitly.
This is a 'vector' (really, a variable-sized array), optimized for the case when the array is small.
void verify(const DominatorTreeBase< BlockT, false > &DomTree) const
DebugLoc getStartLoc() const
Return the debug location of the start of this loop.
bool VerifyLoopInfo
Enable verification of loop info.
This templated class represents "all analyses that operate over <a particular IR unit>" (e....
The main scalar evolution driver.
BranchInst * getLoopGuardBranch() const
Return the loop guard branch, if it exists.
Predicate getInversePredicate() const
For example, EQ -> NE, UGT -> ULE, SLT -> SGE, OEQ -> UNE, UGT -> OLE, OLT -> UGE,...
Concrete subclass of DominatorTreeBase that is used to compute a normal dominator tree.
void print(raw_ostream &OS) const
Instruction::BinaryOps getInductionOpcode() const
Returns binary opcode of the induction operator.
Predicate getFlippedStrictnessPredicate() const
For predicate of kind "is X or equal to 0" returns the predicate "is X".
int getIntLoopAttribute(const Loop *TheLoop, StringRef Name, int Default=0)
Find named metadata for a loop with an integer value.
@ ICMP_SGT
signed greater than
static bool startswith(StringRef Magic, const char(&S)[N])
BinaryOperator * getInductionBinOp() const
The legacy pass manager's analysis pass to compute loop information.
static Value * findFinalIVValue(const Loop &L, const PHINode &IndVar, const Instruction &StepInst)
Return the final value of the loop induction variable if found.
bool isCanonical(ScalarEvolution &SE) const
Return true if the loop induction variable starts at zero and increments by one each time through the...
SmallPtrSet - This class implements a set which is optimized for holding SmallSize or less elements.
MDNode * findOptionMDForLoopID(MDNode *LoopID, StringRef Name)
Find and return the loop attribute node for the attribute Name in LoopID.
void getAnalysisUsage(AnalysisUsage &AU) const override
getAnalysisUsage - This function should be overriden by passes that need analysis information to do t...
static MDTuple * get(LLVMContext &Context, ArrayRef< Metadata * > MDs)
op_range operands() const
LLVM Basic Block Representation.
unsigned getNumOperands() const
Return number of MDNode operands.
static Optional< Loop::LoopBounds > getBounds(const Loop &L, PHINode &IndVar, ScalarEvolution &SE)
Return the LoopBounds object if.
llvm::MDNode * makePostTransformationMetadata(llvm::LLVMContext &Context, MDNode *OrigLoopID, llvm::ArrayRef< llvm::StringRef > RemovePrefixes, llvm::ArrayRef< llvm::MDNode * > AddAttrs)
Create a new LoopID after the loop has been transformed.
raw_ostream & dbgs()
dbgs() - This returns a reference to a raw_ostream for debugging messages.
This is the shared class of boolean and integer constants.
LoopT * getParentLoop() const
Return the parent loop if it exists or nullptr for top level loops.
INITIALIZE_PASS_BEGIN(LoopInfoWrapperPass, "loops", "Natural Loop Information", true, true) INITIALIZE_PASS_END(LoopInfoWrapperPass
bool all_of(R &&range, UnaryPredicate P)
Provide wrappers to std::all_of which take ranges instead of having to pass begin/end explicitly.
void getLoopLatches(SmallVectorImpl< BasicBlock * > &LoopLatches) const
Return all loop latch blocks of this loop.
bool getInductionDescriptor(ScalarEvolution &SE, InductionDescriptor &IndDesc) const
Get the loop induction descriptor for the loop induction variable.
A struct for saving information about induction variables.
void setLoopAlreadyUnrolled()
Add llvm.loop.unroll.disable to this loop's loop id metadata.
void analyze(const DominatorTreeBase< BlockT, false > &DomTree)
Create the loop forest using a stable algorithm.
llvm::Optional< int > getOptionalIntLoopAttribute(const Loop *TheLoop, StringRef Name)
Find named metadata for a loop with an integer value.
static PassRegistry * getPassRegistry()
getPassRegistry - Access the global registry object, which is automatically initialized at applicatio...
static GCRegistry::Add< CoreCLRGC > E("coreclr", "CoreCLR-compatible GC")
void append(in_iter in_start, in_iter in_end)
Add the specified range to the end of the SmallVector.
bool isAnnotatedParallel() const
Returns true if the loop is annotated parallel.
Represent the analysis usage information of a pass.
constexpr T getValueOr(U &&value) const &
iterator_range< block_iterator > blocks() const
Optional< bool > getOptionalBoolLoopAttribute(const Loop *TheLoop, StringRef Name)
void moveToPlace(MemoryUseOrDef *What, BasicBlock *BB, MemorySSA::InsertionPlace Where)
POTIterator begin()
Postorder traversal over the graph.
Value * getIncomingValueForBlock(const BasicBlock *BB) const
LLVM_NODISCARD detail::scope_exit< typename std::decay< Callable >::type > make_scope_exit(Callable &&F)
bool isTokenTy() const
Return true if this is 'token'.
void printLoop(Loop &L, raw_ostream &OS, const std::string &Banner="")
Function to print a loop's contents as LLVM's text IR assembly.
Legacy analysis pass which computes a DominatorTree.
iterator_range< const_phi_iterator > phis() const
Returns a range that iterates over the phis in the basic block.
This class implements an extremely fast bulk output stream that can only output to a stream.
static const char * LLVMLoopMustProgress
bool isMustProgress(const Loop *L)
Return true if this loop can be assumed to make progress.
const Module * getModule() const
Return the module owning the function this basic block belongs to, or nullptr if the function does no...
API to communicate dependencies between analyses during invalidation.
unsigned ID
LLVM IR allows to use arbitrary numbers as calling convention identifiers.
Direction
An enum for the direction of the loop.
LocRange getLocRange() const
Return the source code span of the loop.
MDNode * getMetadata(unsigned KindID) const
Get the metadata of given kind attached to this Instruction.
#define INITIALIZE_PASS_END(passName, arg, name, cfg, analysis)
Value * getCondition() const
const SCEV * getSCEV(Value *V)
Return a SCEV expression for the full generality of the specified expression.
This class is the base class for the comparison instructions.
const MDOperand & getOperand(unsigned I) const
Store the result of a depth first search within basic blocks contained by a single loop.
Value * getStartValue() const
Optional< const MDOperand * > findStringMetadataForLoop(const Loop *TheLoop, StringRef Name)
Find string metadata for loop.
bool isLoopSimplifyForm() const
Return true if the Loop is in the form that the LoopSimplify form transforms loops to,...
This class represents an analyzed expression in the program.
bool willReturn() const
Determine if the function will return.
This instruction compares its operands according to the predicate given to the constructor.
static bool isBlockInLCSSAForm(const Loop &L, const BasicBlock &BB, const DominatorTree &DT)
static GCRegistry::Add< StatepointGC > D("statepoint-example", "an example strategy for statepoint")
MemorySSA * getMemorySSA() const
Get handle on MemorySSA.
INITIALIZE_PASS_DEPENDENCY(DominatorTreeWrapperPass)
static const BasicBlock & skipEmptyBlockUntil(const BasicBlock *From, const BasicBlock *End, bool CheckUniquePred=false)
Recursivelly traverse all empty 'single successor' basic blocks of From (if there are any).
This is an important class for using LLVM in a threaded context.
A special type used by analysis passes to provide an address that identifies that particular analysis...
bool getIncomingAndBackEdge(BasicBlock *&Incoming, BasicBlock *&Backedge) const
Obtain the unique incoming and back edge.
LoopT * getLoopFor(const BlockT *BB) const
Return the inner most loop that BB lives in.
MemoryUseOrDef * getMemoryAccess(const Instruction *I) const
Given a memory Mod/Ref'ing instruction, get the MemorySSA access associated with it.
Interval::succ_iterator succ_begin(Interval *I)
succ_begin/succ_end - define methods so that Intervals may be used just like BasicBlocks can with the...
Direction getDirection() const
Get the direction of the loop.
BasicBlock * getLoopPreheader() const
If there is a preheader for this loop, return it.
bool is_contained(R &&Range, const E &Element)
Wrapper function around std::find to detect if an element exists in a container.
void perform(LoopInfo *LI)
Traverse the loop blocks and store the DFS result.
static MDString * get(LLVMContext &Context, StringRef Str)
BasicBlock * getLoopLatch() const
If there is a single latch block for this loop, return it.
A range representing the start and end location of a loop.
bool hasDedicatedExits() const
Return true if no exit block for the loop has a predecessor that is outside the loop.
ConstantInt * getConstIntStepValue() const
assert(ImpDefSCC.getReg()==AMDGPU::SCC &&ImpDefSCC.isDef())
bool isFinite(const Loop *L)
Return true if this loop can be assumed to run for a finite number of iterations.
void swap(llvm::BitVector &LHS, llvm::BitVector &RHS)
Implement std::swap in terms of BitVector swap.
bool isReachableFromEntry(const Use &U) const
Provide an overload for a Use.
void erase(Loop *L)
Update LoopInfo after removing the last backedge from a loop.
A Module instance is used to store all the information related to an LLVM module.
void print(raw_ostream &O, const Module *M=nullptr) const override
print - Print out the internal state of the pass.
std::vector< BasicBlock * >::const_iterator POIterator
Postorder list iterators.
size_type count(ConstPtrType Ptr) const
count - Return 1 if the specified pointer is in the set, 0 otherwise.
void printAsOperand(raw_ostream &O, bool PrintType=true, const Module *M=nullptr) const
Print the name of this Value out to the specified raw_ostream.
bool isUnconditional() const
@ ICMP_SLT
signed less than
LoopT * removeChildLoop(iterator I)
This removes the specified child from being a subloop of this loop.
ArrayRef - Represent a constant reference to an array (0 or more elements consecutively in memory),...
bool any_of(R &&range, UnaryPredicate P)
Provide wrappers to std::any_of which take ranges instead of having to pass begin/end explicitly.
StringRef - Represent a constant reference to a string, i.e.
bool makeLoopInvariant(Value *V, bool &Changed, Instruction *InsertPt=nullptr, MemorySSAUpdater *MSSAU=nullptr) const
If the given value is an instruction inside of the loop and it can be hoisted, do so to make it trivi...
PHINode * getCanonicalInductionVariable() const
Check to see if the loop has a canonical induction variable: an integer recurrence that starts at 0 a...
#define llvm_unreachable(msg)
Marks that the current location is not supposed to be reachable.
Type * getType() const
All values are typed, get the type of this value.
Represents analyses that only rely on functions' control flow.
const SCEV * getStep() const
bool isOutermost() const
Return true if the loop does not have a parent (natural) loop.
const BasicBlock * getUniquePredecessor() const
Return the predecessor of this block if it has a unique predecessor block.
void verifyAnalysis() const override
verifyAnalysis() - This member can be implemented by a analysis pass to check state of analysis infor...
MachineBasicBlock MachineBasicBlock::iterator DebugLoc DL
add sub stmia L5 ldr r0 bl L_printf $stub Instead of a and a wouldn t it be better to do three moves *Return an aggregate type is even return S
Core dominator tree base class.
MDNode * findOptionMDForLoop(const Loop *TheLoop, StringRef Name)
Find string metadata for a loop.
int64_t getSExtValue() const
Return the constant as a 64-bit integer value after it has been sign extended as appropriate for the ...
bool hasLoopInvariantOperands(const Instruction *I) const
Return true if all the operands of the specified instruction are loop invariant.
static MDTuple * getDistinct(LLVMContext &Context, ArrayRef< Metadata * > MDs)
LoopInfo run(Function &F, FunctionAnalysisManager &AM)
Optional< LoopBounds > getBounds(ScalarEvolution &SE) const
Return the struct LoopBounds collected if all struct members are found, else None.
bool isLoopInvariant(const SCEV *S, const Loop *L)
Return true if the value of the given SCEV is unchanging in the specified loop.
const DebugLoc & getStart() const
LLVMContext & getContext() const
Get the context in which this basic block lives.
static bool runOnFunction(Function &F, bool PostInlining)
bool isInnermost() const
Return true if the loop does not contain any (natural) loops.
static bool isInductionPHI(PHINode *Phi, const Loop *L, ScalarEvolution *SE, InductionDescriptor &D, const SCEV *Expr=nullptr, SmallVectorImpl< Instruction * > *CastsToIgnore=nullptr)
Returns true if Phi is an induction in the loop L.
Below are some utilities to get the loop guard, loop bounds and induction variable,...
bool isValidAsAccessGroup(MDNode *AccGroup)
Return whether an MDNode might represent an access group.
void setLoopID(MDNode *LoopID) const
Set the llvm.loop loop id metadata for this loop.
bool isLCSSAForm(const DominatorTree &DT) const
Return true if the Loop is in LCSSA form.
void setPreservesAll()
Set by analyses that do not transform their input at all.
static PreservedAnalyses all()
Construct a special preserved set that preserves all passes.
bool isAuxiliaryInductionVariable(PHINode &AuxIndVar, ScalarEvolution &SE) const
Return true if the given PHINode AuxIndVar is.
ICmpInst::Predicate getCanonicalPredicate() const
Return the canonical predicate for the latch compare instruction, if able to be calcuated.
bool isInvalid() const
Return true if this loop is no longer valid.
Interval::pred_iterator pred_end(Interval *I)
MDNode * getLoopID() const
Return the llvm.loop loop id metadata node for this loop if it is present.
This node represents a polynomial recurrence on the trip count of the specified loop.
BasicBlock * getHeader() const
bool isRecursivelyLCSSAForm(const DominatorTree &DT, const LoopInfo &LI) const
Return true if this Loop and all inner subloops are in LCSSA form.
bool mustProgress() const
Determine if the function is required to make forward progress.
void setLoopMustProgress()
Add llvm.loop.mustprogress to this loop's loop id metadata.
void replaceOperandWith(unsigned I, Metadata *New)
Replace a specific operand.
Interval::pred_iterator pred_begin(Interval *I)
pred_begin/pred_end - define methods so that Intervals may be used just like BasicBlocks can with the...
Analysis pass which computes a DominatorTree.
bool hasMustProgress(const Loop *L)
Look for the loop attribute that requires progress within the loop.
std::vector< Loop * >::const_iterator iterator
bool getBooleanLoopAttribute(const Loop *TheLoop, StringRef Name)
Returns true if Name is applied to TheLoop and enabled.
const BasicBlock * getParent() const
bool isSafeToClone() const
Return true if the loop body is safe to clone in practice.
Predicate getPredicate() const
Return the predicate for this instruction.
static cl::opt< bool, true > VerifyLoopInfoX("verify-loop-info", cl::location(VerifyLoopInfo), cl::Hidden, cl::desc("Verify loop info (time consuming)"))
const Instruction * getTerminator() const LLVM_READONLY
Returns the terminator instruction if the block is well formed or null if the block is not well forme...
std::vector< Loop * >::const_iterator iterator
iterator/begin/end - The interface to the top-level loops in the current function.
bool forcePrintModuleIR()
AnalysisUsage & addRequiredTransitive()
PreservedAnalysisChecker getChecker() const
Build a checker for this PreservedAnalyses and the specified analysis type.
A container for analyses that lazily runs them and caches their results.
FunctionPass class - This class is used to implement most global optimizations.
bool isOne() const
This is just a convenience method to make client code smaller for a common case.
void print(raw_ostream &OS, bool Verbose=false, bool PrintNested=true, unsigned Depth=0) const
Print loop with all the BBs inside it.
Common register allocation spilling lr str ldr sxth r3 ldr mla r4 can lr mov lr str ldr sxth r3 mla r4 and then merge mul and lr str ldr sxth r3 mla r4 It also increase the likelihood the store may become dead bb27 Successors according to LLVM BB
PHINode * getInductionVariable(ScalarEvolution &SE) const
Return the loop induction variable if found, else return nullptr.
bool isRotatedForm() const
Return true if the loop is in rotated form.
Value * getOperand(unsigned i) const
Conditional or Unconditional Branch instruction.
LLVM Value Representation.
PreservedAnalyses run(Function &F, FunctionAnalysisManager &AM)
iterator_range< user_iterator > users()
bool isConditional() const
Tracking metadata reference owned by Metadata.
BasicBlock * getSuccessor(unsigned i) const
Analysis pass that exposes the LoopInfo for a function.
bool wouldBeOutOfLoopUseRequiringLCSSA(const Value *V, const BasicBlock *ExitBB) const
A Use represents the edge between a Value definition and its users.
std::pair< iterator, bool > insert(PtrType Ptr)
Inserts Ptr if and only if there is no element in the container equal to Ptr.