LLVM  16.0.0git
Macros | Functions | Variables
LoopPredication.cpp File Reference
#include "llvm/Transforms/Scalar/LoopPredication.h"
#include "llvm/ADT/Statistic.h"
#include "llvm/Analysis/AliasAnalysis.h"
#include "llvm/Analysis/BranchProbabilityInfo.h"
#include "llvm/Analysis/GuardUtils.h"
#include "llvm/Analysis/LoopInfo.h"
#include "llvm/Analysis/LoopPass.h"
#include "llvm/Analysis/MemorySSA.h"
#include "llvm/Analysis/MemorySSAUpdater.h"
#include "llvm/Analysis/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/IntrinsicInst.h"
#include "llvm/IR/Module.h"
#include "llvm/IR/PatternMatch.h"
#include "llvm/InitializePasses.h"
#include "llvm/Pass.h"
#include "llvm/Support/CommandLine.h"
#include "llvm/Support/Debug.h"
#include "llvm/Transforms/Scalar.h"
#include "llvm/Transforms/Utils/GuardUtils.h"
#include "llvm/Transforms/Utils/Local.h"
#include "llvm/Transforms/Utils/LoopUtils.h"
#include "llvm/Transforms/Utils/ScalarEvolutionExpander.h"
#include <optional>
Include dependency graph for LoopPredication.cpp:

Go to the source code of this file.

Macros

#define DEBUG_TYPE   "loop-predication"
 

Functions

 STATISTIC (TotalConsidered, "Number of guards considered")
 
 STATISTIC (TotalWidened, "Number of checks widened")
 
 INITIALIZE_PASS_BEGIN (LoopPredicationLegacyPass, "loop-predication", "Loop predication", false, false) INITIALIZE_PASS_END(LoopPredicationLegacyPass
 
static bool isSafeToTruncateWideIVType (const DataLayout &DL, ScalarEvolution &SE, const LoopICmp LatchCheck, Type *RangeCheckType)
 
static std::optional< LoopICmp > generateLoopLatchCheck (const DataLayout &DL, ScalarEvolution &SE, const LoopICmp LatchCheck, Type *RangeCheckType)
 
static void normalizePredicate (ScalarEvolution *SE, Loop *L, LoopICmp &RC)
 
static BranchInstFindWidenableTerminatorAboveLoop (Loop *L, LoopInfo &LI)
 If we can (cheaply) find a widenable branch which controls entry into the loop, return it. More...
 
static const SCEVgetMinAnalyzeableBackedgeTakenCount (ScalarEvolution &SE, DominatorTree &DT, Loop *L)
 Return the minimum of all analyzeable exit counts. More...
 

Variables

static cl::opt< bool > EnableIVTruncation ("loop-predication-enable-iv-truncation", cl::Hidden, cl::init(true))
 
static cl::opt< bool > EnableCountDownLoop ("loop-predication-enable-count-down-loop", cl::Hidden, cl::init(true))
 
static cl::opt< bool > SkipProfitabilityChecks ("loop-predication-skip-profitability-checks", cl::Hidden, cl::init(false))
 
static cl::opt< float > LatchExitProbabilityScale ("loop-predication-latch-probability-scale", cl::Hidden, cl::init(2.0), cl::desc("scale factor for the latch probability. Value should be greater " "than 1. Lower values are ignored"))
 
static cl::opt< bool > PredicateWidenableBranchGuards ("loop-predication-predicate-widenable-branches-to-deopt", cl::Hidden, cl::desc("Whether or not we should predicate guards " "expressed as widenable branches to deoptimize blocks"), cl::init(true))
 
static cl::opt< bool > InsertAssumesOfPredicatedGuardsConditions ("loop-predication-insert-assumes-of-predicated-guards-conditions", cl::Hidden, cl::desc("Whether or not we should insert assumes of conditions of " "predicated guards"), cl::init(true))
 
loop predication
 
loop Loop false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "loop-predication"

Definition at line 205 of file LoopPredication.cpp.

Function Documentation

◆ FindWidenableTerminatorAboveLoop()

static BranchInst* FindWidenableTerminatorAboveLoop ( Loop L,
LoopInfo LI 
)
static

If we can (cheaply) find a widenable branch which controls entry into the loop, return it.

Definition at line 1053 of file LoopPredication.cpp.

References BB, Cond, llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), llvm::parseWidenableBranch(), and llvm::M68kBeads::Term.

◆ generateLoopLatchCheck()

static std::optional<LoopICmp> generateLoopLatchCheck ( const DataLayout DL,
ScalarEvolution SE,
const LoopICmp  LatchCheck,
Type RangeCheckType 
)
static

◆ getMinAnalyzeableBackedgeTakenCount()

static const SCEV* getMinAnalyzeableBackedgeTakenCount ( ScalarEvolution SE,
DominatorTree DT,
Loop L 
)
static

Return the minimum of all analyzeable exit counts.

This is an upper bound on the actual exit count. If there are not at least two analyzeable exits, returns SCEVCouldNotCompute.

Definition at line 1087 of file LoopPredication.cpp.

References assert(), llvm::DominatorTree::dominates(), llvm::ScalarEvolution::getCouldNotCompute(), llvm::ScalarEvolution::getExitCount(), llvm::LoopBase< BlockT, LoopT >::getExitingBlocks(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), and llvm::ScalarEvolution::getUMinFromMismatchedTypes().

◆ INITIALIZE_PASS_BEGIN()

INITIALIZE_PASS_BEGIN ( LoopPredicationLegacyPass  ,
"loop-predication ,
"Loop predication ,
false  ,
false   
)

◆ isSafeToTruncateWideIVType()

static bool isSafeToTruncateWideIVType ( const DataLayout DL,
ScalarEvolution SE,
const LoopICmp  LatchCheck,
Type RangeCheckType 
)
static

◆ normalizePredicate()

static void normalizePredicate ( ScalarEvolution SE,
Loop L,
LoopICmp &  RC 
)
static

◆ STATISTIC() [1/2]

STATISTIC ( TotalConsidered  ,
"Number of guards considered"   
)

◆ STATISTIC() [2/2]

STATISTIC ( TotalWidened  ,
"Number of checks widened"   
)

Variable Documentation

◆ EnableCountDownLoop

cl::opt<bool> EnableCountDownLoop("loop-predication-enable-count-down-loop", cl::Hidden, cl::init(true))
static

◆ EnableIVTruncation

cl::opt<bool> EnableIVTruncation("loop-predication-enable-iv-truncation", cl::Hidden, cl::init(true))
static

◆ false

loop Loop false

Definition at line 364 of file LoopPredication.cpp.

◆ InsertAssumesOfPredicatedGuardsConditions

cl::opt<bool> InsertAssumesOfPredicatedGuardsConditions("loop-predication-insert-assumes-of-predicated-guards-conditions", cl::Hidden, cl::desc("Whether or not we should insert assumes of conditions of " "predicated guards"), cl::init(true))
static

◆ LatchExitProbabilityScale

cl::opt<float> LatchExitProbabilityScale("loop-predication-latch-probability-scale", cl::Hidden, cl::init(2.0), cl::desc("scale factor for the latch probability. Value should be greater " "than 1. Lower values are ignored"))
static

◆ PredicateWidenableBranchGuards

cl::opt<bool> PredicateWidenableBranchGuards("loop-predication-predicate-widenable-branches-to-deopt", cl::Hidden, cl::desc("Whether or not we should predicate guards " "expressed as widenable branches to deoptimize blocks"), cl::init(true))
static

◆ predication

loop Loop predication

Definition at line 363 of file LoopPredication.cpp.

◆ SkipProfitabilityChecks

cl::opt<bool> SkipProfitabilityChecks("loop-predication-skip-profitability-checks", cl::Hidden, cl::init(false))
static