LLVM
15.0.0git
|
Below are some utilities to get the loop guard, loop bounds and induction variable, and to check if a given phinode is an auxiliary induction variable, if the loop is guarded, and if the loop is canonical. More...
#include "llvm/Analysis/LoopInfo.h"
Public Types | |
enum | Direction { Direction::Increasing, Direction::Decreasing, Direction::Unknown } |
An enum for the direction of the loop. More... | |
Public Member Functions | |
Value & | getInitialIVValue () const |
Get the initial value of the loop induction variable. More... | |
Instruction & | getStepInst () const |
Get the instruction that updates the loop induction variable. More... | |
Value * | getStepValue () const |
Get the step that the loop induction variable gets updated by in each loop iteration. More... | |
Value & | getFinalIVValue () const |
Get the final value of the loop induction variable. More... | |
ICmpInst::Predicate | getCanonicalPredicate () const |
Return the canonical predicate for the latch compare instruction, if able to be calcuated. More... | |
Direction | getDirection () const |
Get the direction of the loop. More... | |
Static Public Member Functions | |
static Optional< Loop::LoopBounds > | getBounds (const Loop &L, PHINode &IndVar, ScalarEvolution &SE) |
Return the LoopBounds object if. More... | |
Below are some utilities to get the loop guard, loop bounds and induction variable, and to check if a given phinode is an auxiliary induction variable, if the loop is guarded, and if the loop is canonical.
Here is an example:
if (guardcmp) goto preheader; else goto afterloop
Definition at line 657 of file LoopInfo.h.
|
strong |
An enum for the direction of the loop.
Enumerator | |
---|---|
Increasing | |
Decreasing | |
Unknown |
Definition at line 720 of file LoopInfo.h.
|
static |
Return the LoopBounds object if.
IndVar
is an induction variableElse None.
Definition at line 197 of file LoopInfo.cpp.
References findFinalIVValue(), llvm::InductionDescriptor::getInductionBinOp(), llvm::User::getOperand(), llvm::ScalarEvolution::getSCEV(), llvm::InductionDescriptor::getStartValue(), llvm::InductionDescriptor::getStep(), llvm::InductionDescriptor::isInductionPHI(), and llvm::None.
Referenced by llvm::Loop::getBounds().
ICmpInst::Predicate Loop::LoopBounds::getCanonicalPredicate | ( | ) | const |
Return the canonical predicate for the latch compare instruction, if able to be calcuated.
Else BAD_ICMP_PREDICATE.
A predicate is considered as canonical if requirements below are all satisfied:
Here is an example when both (1) and (2) are not satisfied:
The predicate would be sgt if both (1) and (2) are satisfied. getCanonicalPredicate() returns sgt for this example. Note: The IR is not changed.
Definition at line 228 of file LoopInfo.cpp.
References assert(), llvm::CmpInst::BAD_ICMP_PREDICATE, D, llvm::BranchInst::getCondition(), llvm::CmpInst::getFlippedStrictnessPredicate(), llvm::CmpInst::getInversePredicate(), llvm::User::getOperand(), llvm::CmpInst::getPredicate(), llvm::BranchInst::getSuccessor(), llvm::CmpInst::getSwappedPredicate(), llvm::BasicBlock::getTerminator(), llvm::CmpInst::ICMP_EQ, llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLT, and llvm::BranchInst::isConditional().
Direction Loop::LoopBounds::getDirection | ( | ) | const |
Get the direction of the loop.
Definition at line 270 of file LoopInfo.cpp.
References llvm::pdb::Unknown.
|
inline |
Get the final value of the loop induction variable.
Definition at line 679 of file LoopInfo.h.
|
inline |
Get the initial value of the loop induction variable.
Definition at line 669 of file LoopInfo.h.
|
inline |
Get the instruction that updates the loop induction variable.
Definition at line 672 of file LoopInfo.h.
Referenced by checkSafeInstruction().
|
inline |
Get the step that the loop induction variable gets updated by in each loop iteration.
Return nullptr if not found.
Definition at line 676 of file LoopInfo.h.