LLVM 20.0.0git
|
This class represents a loop nest and can be used to query its properties. More...
#include "llvm/Analysis/LoopNestAnalysis.h"
Public Types | |
using | InstrVectorTy = SmallVector< const Instruction * > |
Public Member Functions | |
LoopNest (Loop &Root, ScalarEvolution &SE) | |
Construct a loop nest rooted by loop Root . | |
LoopNest ()=delete | |
Loop & | getOutermostLoop () const |
Return the outermost loop in the loop nest. | |
Loop * | getInnermostLoop () const |
Return the innermost loop in the loop nest if the nest has only one innermost loop, and a nullptr otherwise. | |
Loop * | getLoop (unsigned Index) const |
Return the loop at the given Index . | |
unsigned | getLoopIndex (const Loop &L) const |
Get the loop index of the given loop L . | |
size_t | getNumLoops () const |
Return the number of loops in the nest. | |
ArrayRef< Loop * > | getLoops () const |
Get the loops in the nest. | |
LoopVectorTy | getLoopsAtDepth (unsigned Depth) const |
Get the loops in the nest at the given Depth . | |
SmallVector< LoopVectorTy, 4 > | getPerfectLoops (ScalarEvolution &SE) const |
Retrieve a vector of perfect loop nests contained in the current loop nest. | |
unsigned | getNestDepth () const |
Return the loop nest depth (i.e. | |
unsigned | getMaxPerfectDepth () const |
Return the maximum perfect nesting depth. | |
bool | areAllLoopsSimplifyForm () const |
Return true if all loops in the loop nest are in simplify form. | |
bool | areAllLoopsRotatedForm () const |
Return true if all loops in the loop nest are in rotated form. | |
Function * | getParent () const |
Return the function to which the loop-nest belongs. | |
StringRef | getName () const |
Static Public Member Functions | |
static std::unique_ptr< LoopNest > | getLoopNest (Loop &Root, ScalarEvolution &SE) |
Construct a LoopNest object. | |
static bool | arePerfectlyNested (const Loop &OuterLoop, const Loop &InnerLoop, ScalarEvolution &SE) |
Return true if the given loops OuterLoop and InnerLoop are perfectly nested with respect to each other, and false otherwise. | |
static InstrVectorTy | getInterveningInstructions (const Loop &OuterLoop, const Loop &InnerLoop, ScalarEvolution &SE) |
Return a vector of instructions that prevent the LoopNest given by loops OuterLoop and InnerLoop from being perfect. | |
static unsigned | getMaxPerfectDepth (const Loop &Root, ScalarEvolution &SE) |
Return the maximum nesting depth of the loop nest rooted by loop Root . | |
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). | |
Protected Attributes | |
const unsigned | MaxPerfectDepth |
LoopVectorTy | Loops |
This class represents a loop nest and can be used to query its properties.
Definition at line 28 of file LoopNestAnalysis.h.
using llvm::LoopNest::InstrVectorTy = SmallVector<const Instruction *> |
Definition at line 30 of file LoopNestAnalysis.h.
LoopNest::LoopNest | ( | Loop & | Root, |
ScalarEvolution & | SE | ||
) |
Construct a loop nest rooted by loop Root
.
Definition at line 42 of file LoopNestAnalysis.cpp.
References llvm::append_range(), llvm::breadth_first(), and Loops.
|
delete |
|
inline |
Return true if all loops in the loop nest are in rotated form.
Definition at line 171 of file LoopNestAnalysis.h.
References llvm::all_of(), and Loops.
|
inline |
Return true if all loops in the loop nest are in simplify form.
Definition at line 166 of file LoopNestAnalysis.h.
References llvm::all_of(), and Loops.
|
static |
Return true if the given loops OuterLoop
and InnerLoop
are perfectly nested with respect to each other, and false otherwise.
Example:
arePerfectlyNested(loop_i, loop_j, SE) would return true. arePerfectlyNested(loop_j, loop_k, SE) would return true. arePerfectlyNested(loop_i, loop_k, SE) would return false.
Definition at line 103 of file LoopNestAnalysis.cpp.
Referenced by getMaxPerfectDepth(), and getPerfectLoops().
|
inline |
Return the innermost loop in the loop nest if the nest has only one innermost loop, and a nullptr otherwise.
Note: the innermost loop returned is not necessarily perfectly nested.
Definition at line 85 of file LoopNestAnalysis.h.
References llvm::LoopBase< BlockT, LoopT >::getLoopDepth(), and Loops.
|
static |
Return a vector of instructions that prevent the LoopNest given by loops OuterLoop
and InnerLoop
from being perfect.
Definition at line 181 of file LoopNestAnalysis.cpp.
References checkSafeInstruction(), llvm::dbgs(), DEBUG_WITH_TYPE, llvm::Loop::getBounds(), llvm::LoopBase< BlockT, LoopT >::getExitBlock(), llvm::LoopBase< BlockT, LoopT >::getHeader(), getInnerLoopGuardCmp(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), getOuterLoopLatchCmp(), I, LLVM_DEBUG, and VerboseDebug.
Return the loop at the given Index
.
Definition at line 100 of file LoopNestAnalysis.h.
Get the loop index of the given loop L
.
Definition at line 106 of file LoopNestAnalysis.h.
References I, and llvm_unreachable.
|
static |
Construct a LoopNest object.
Definition at line 47 of file LoopNestAnalysis.cpp.
Referenced by llvm::LoopNestPrinterPass::run(), and llvm::PassManager< Loop, LoopAnalysisManager, LoopStandardAnalysisResults &, LPMUpdater & >::runWithLoopNestPasses().
Get the loops in the nest.
Definition at line 117 of file LoopNestAnalysis.h.
References Loops.
Referenced by llvm::operator<<(), llvm::LoopInterchangePass::run(), llvm::LoopFlattenPass::run(), and tryToUnrollAndJamLoop().
|
inline |
Get the loops in the nest at the given Depth
.
Definition at line 120 of file LoopNestAnalysis.h.
References assert(), llvm::Depth, I, and Loops.
|
inline |
Return the maximum perfect nesting depth.
Definition at line 163 of file LoopNestAnalysis.h.
|
static |
Return the maximum nesting depth of the loop nest rooted by loop Root
.
For example given the loop nest:
getMaxPerfectDepth(Loop_i) would return 2.
Definition at line 261 of file LoopNestAnalysis.cpp.
References arePerfectlyNested(), llvm::dbgs(), llvm::Loop::getName(), llvm::LoopBase< BlockT, LoopT >::getSubLoops(), and LLVM_DEBUG.
Referenced by llvm::operator<<().
|
inline |
Definition at line 180 of file LoopNestAnalysis.h.
References Loops.
|
inline |
Return the loop nest depth (i.e.
the loop depth of the 'deepest' loop) For example given the loop nest:
getNestDepth() would return 3.
Definition at line 155 of file LoopNestAnalysis.h.
References assert(), and Loops.
Referenced by llvm::operator<<().
|
inline |
Return the number of loops in the nest.
Definition at line 114 of file LoopNestAnalysis.h.
References Loops.
|
inline |
Return the outermost loop in the loop nest.
Definition at line 80 of file LoopNestAnalysis.h.
References Loops.
Referenced by llvm::operator<<(), llvm::LNICMPass::run(), llvm::LoopInterchangePass::run(), and tryToUnrollAndJamLoop().
|
inline |
Return the function to which the loop-nest belongs.
Definition at line 176 of file LoopNestAnalysis.h.
References Loops.
Referenced by llvm::LNICMPass::run(), llvm::LoopInterchangePass::run(), and llvm::LoopUnrollAndJamPass::run().
SmallVector< LoopVectorTy, 4 > LoopNest::getPerfectLoops | ( | ScalarEvolution & | SE | ) | const |
Retrieve a vector of perfect loop nests contained in the current loop nest.
For example, given the following nest containing 4 loops, this member function would return {{L1,L2},{L3,L4}}.
Definition at line 241 of file LoopNestAnalysis.cpp.
References arePerfectlyNested(), llvm::SmallVectorImpl< T >::clear(), llvm::depth_first(), llvm::SmallVectorBase< Size_T >::empty(), llvm::SmallVectorTemplateCommon< T, typename >::front(), Loops, and llvm::SmallVectorTemplateBase< T, bool >::push_back().
|
static |
Recursivelly traverse all empty 'single successor' basic blocks of From
(if there are any).
When CheckUniquePred
is set to true, check if each of the empty single successors has a unique predecessor. Return the last basic block found or End
if it was reached during the search.
Definition at line 288 of file LoopNestAnalysis.cpp.
References assert(), llvm::SmallPtrSetImpl< PtrType >::count(), End, From, llvm::BasicBlock::getUniquePredecessor(), llvm::BasicBlock::getUniqueSuccessor(), and llvm::SmallPtrSetImpl< PtrType >::insert().
Referenced by llvm::Loop::getLoopGuardBranch().
|
protected |
Definition at line 184 of file LoopNestAnalysis.h.
Referenced by getPerfectLoops(), and LoopNest().
Definition at line 183 of file LoopNestAnalysis.h.