|
LLVM
10.0.0
|
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 afterloopDefinition at line 614 of file LoopInfo.h.
|
strong |
An enum for the direction of the loop.
| Enumerator | |
|---|---|
| Increasing | |
| Decreasing | |
| Unknown | |
Definition at line 677 of file LoopInfo.h.
|
static |
Return the LoopBounds object if.
IndVar is an induction variableElse None.
Definition at line 199 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 230 of file LoopInfo.cpp.
References assert(), llvm::CmpInst::BAD_ICMP_PREDICATE, D, llvm::dyn_cast(), llvm::BranchInst::getCondition(), llvm::CmpInst::getFlippedStrictnessPredicate(), 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 272 of file LoopInfo.cpp.
References llvm::Unknown.
|
inline |
Get the final value of the loop induction variable.
Definition at line 636 of file LoopInfo.h.
|
inline |
Get the initial value of the loop induction variable.
Definition at line 626 of file LoopInfo.h.
|
inline |
Get the instruction that updates the loop induction variable.
Definition at line 629 of file LoopInfo.h.
|
inline |
Get the step that the loop induction variable gets updated by in each loop iteration.
Return nullptr if not found.
Definition at line 633 of file LoopInfo.h.
1.8.13