LLVM 22.0.0git
LoopUtils.cpp File Reference

Go to the source code of this file.

Classes

struct  DbgLoop
struct  RewritePhi
struct  PointerBounds
 IR Values for the lower and upper bounds of a pointer evolution. More...

Macros

#define DEBUG_TYPE   "loop-utils"

Functions

static MDNodecreateStringMetadata (Loop *TheLoop, StringRef Name, unsigned V)
 Create MDNode for input string.
static BranchInstgetExpectedExitLoopLatchBranch (Loop *L)
 Checks if L has an exiting latch branch.
static raw_ostreamoperator<< (raw_ostream &OS, DbgLoop D)
static std::optional< unsignedestimateLoopTripCount (Loop *L)
static bool hasHardUserWithinLoop (const Loop *L, const Instruction *I)
static bool canLoopBeDeleted (Loop *L, SmallVector< RewritePhi, 8 > &RewritePhiSet)
static bool checkIsIndPhi (PHINode *Phi, Loop *L, ScalarEvolution *SE, InductionDescriptor &ID)
 Checks if it is safe to call InductionDescriptor::isInductionPHI for Phi, and returns true if this Phi is an induction phi in the loop.
static PointerBounds expandBounds (const RuntimeCheckingPtrGroup *CG, Loop *TheLoop, Instruction *Loc, SCEVExpander &Exp, bool HoistRuntimeChecks)
 Expand code for the lower and upper bound of the pointer group CG in TheLoop.
static SmallVector< std::pair< PointerBounds, PointerBounds >, 4 > expandBounds (const SmallVectorImpl< RuntimePointerCheck > &PointerChecks, Loop *L, Instruction *Loc, SCEVExpander &Exp, bool HoistRuntimeChecks)
 Turns a collection of checks into a collection of expanded upper and lower bounds for both pointers in the check.

Variables

static const charLLVMLoopDisableNonforced = "llvm.loop.disable_nonforced"
static const charLLVMLoopDisableLICM = "llvm.licm.disable"

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "loop-utils"

Definition at line 53 of file LoopUtils.cpp.

Function Documentation

◆ canLoopBeDeleted()

bool canLoopBeDeleted ( Loop * L,
SmallVector< RewritePhi, 8 > & RewritePhiSet )
static

◆ checkIsIndPhi()

bool checkIsIndPhi ( PHINode * Phi,
Loop * L,
ScalarEvolution * SE,
InductionDescriptor & ID )
static

Checks if it is safe to call InductionDescriptor::isInductionPHI for Phi, and returns true if this Phi is an induction phi in the loop.

When isInductionPHI returns true, ID will be also be set by isInductionPHI.

Definition at line 1647 of file LoopUtils.cpp.

References llvm::InductionDescriptor::isInductionPHI().

Referenced by llvm::rewriteLoopExitValues().

◆ createStringMetadata()

◆ estimateLoopTripCount()

◆ expandBounds() [1/2]

◆ expandBounds() [2/2]

SmallVector< std::pair< PointerBounds, PointerBounds >, 4 > expandBounds ( const SmallVectorImpl< RuntimePointerCheck > & PointerChecks,
Loop * L,
Instruction * Loc,
SCEVExpander & Exp,
bool HoistRuntimeChecks )
static

Turns a collection of checks into a collection of expanded upper and lower bounds for both pointers in the check.

Definition at line 2046 of file LoopUtils.cpp.

References Check, expandBounds(), llvm::First, HoistRuntimeChecks, and llvm::transform().

◆ getExpectedExitLoopLatchBranch()

BranchInst * getExpectedExitLoopLatchBranch ( Loop * L)
static

Checks if L has an exiting latch branch.

There may also be other exiting blocks. Returns branch instruction terminating the loop latch if above check is successful, nullptr otherwise.

Definition at line 791 of file LoopUtils.cpp.

References assert(), llvm::dyn_cast(), llvm::BranchInst::getNumSuccessors(), llvm::BranchInst::getSuccessor(), and llvm::BasicBlock::getTerminator().

Referenced by estimateLoopTripCount(), llvm::getLoopEstimatedTripCount(), and llvm::setLoopEstimatedTripCount().

◆ hasHardUserWithinLoop()

◆ operator<<()

raw_ostream & operator<< ( raw_ostream & OS,
DbgLoop D )
inlinestatic

Definition at line 813 of file LoopUtils.cpp.

References D().

Variable Documentation

◆ LLVMLoopDisableLICM

const char* LLVMLoopDisableLICM = "llvm.licm.disable"
static

Definition at line 56 of file LoopUtils.cpp.

Referenced by llvm::hasDisableLICMTransformsHint().

◆ LLVMLoopDisableNonforced

const char* LLVMLoopDisableNonforced = "llvm.loop.disable_nonforced"
static

Definition at line 55 of file LoopUtils.cpp.

Referenced by llvm::hasDisableAllTransformsHint().