LLVM  11.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/ScalarEvolution.h"
#include "llvm/Analysis/ScalarEvolutionExpressions.h"
#include "llvm/IR/Function.h"
#include "llvm/IR/GlobalValue.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 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 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< boolEnableIVTruncation ("loop-predication-enable-iv-truncation", cl::Hidden, cl::init(true))
 
static cl::opt< boolEnableCountDownLoop ("loop-predication-enable-count-down-loop", cl::Hidden, cl::init(true))
 
static cl::opt< boolSkipProfitabilityChecks ("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< boolPredicateWidenableBranchGuards ("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))
 
loop predication
 
loop Loop false
 

Macro Definition Documentation

◆ DEBUG_TYPE

#define DEBUG_TYPE   "loop-predication"

Definition at line 203 of file LoopPredication.cpp.

Function Documentation

◆ FindWidenableTerminatorAboveLoop()

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

◆ generateLoopLatchCheck()

static 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 1003 of file LoopPredication.cpp.

References assert(), B, llvm::LoopBase< BlockT, LoopT >::blocks(), Cond, llvm::LoopBase< BlockT, LoopT >::contains(), llvm::IRBuilderBase::CreateFreeze(), llvm::IRBuilderBase::CreateICmp(), llvm::IRBuilderBase::CreateZExt(), llvm::dbgs(), DL, llvm::DominatorTree::dominates(), llvm::Loop::dump(), llvm::dyn_cast(), llvm::SmallVectorBase< SmallVectorSizeType< T > >::empty(), llvm::SCEVExpander::expandCodeFor(), FindWidenableTerminatorAboveLoop(), llvm::ConstantInt::get(), llvm::BranchInst::getCondition(), llvm::BasicBlock::getContext(), llvm::ScalarEvolution::getCouldNotCompute(), llvm::ScalarEvolution::getExitCount(), llvm::LoopBase< BlockT, LoopT >::getExitingBlocks(), llvm::Module::getFunction(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), llvm::BasicBlock::getModule(), llvm::Intrinsic::getName(), llvm::BasicBlock::getPostdominatingDeoptimizeCall(), llvm::BranchInst::getSuccessor(), llvm::ConstantInt::getTrue(), llvm::SCEV::getType(), llvm::Value::getType(), llvm::ScalarEvolution::getUMinFromMismatchedTypes(), I, llvm::CmpInst::ICMP_UGT, llvm::isGuard(), llvm::isGuardAsWidenableBranch(), llvm::Type::isPointerTy(), llvm::isSafeToExpandAt(), LLVM_DEBUG, llvm::parseWidenableBranch(), PredicateWidenableBranchGuards, llvm::SmallVectorTemplateBase< T >::push_back(), Rewriter, llvm::BranchInst::setCondition(), llvm::SCEVExpander::setInsertPoint(), llvm::SmallVectorBase< SmallVectorSizeType< T > >::size(), llvm::succ_begin(), llvm::Value::use_empty(), and llvm::widenWidenableBranch().

◆ 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

Definition at line 659 of file LoopPredication.cpp.

References assert(), Builder, llvm::IRBuilderBase::CreateAnd(), llvm::dbgs(), DL, llvm::Value::dump(), llvm::dyn_cast(), llvm::SmallVectorBase< Size_T >::empty(), generateLoopLatchCheck(), llvm::BranchInst::getCondition(), llvm::LoopBase< BlockT, LoopT >::getExitEdges(), llvm::LoopBase< BlockT, LoopT >::getHeader(), llvm::CmpInst::getInversePredicate(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::User::getOperand(), llvm::BranchInst::getSuccessor(), llvm::BasicBlock::getTerminator(), llvm::SCEV::getType(), llvm::CmpInst::ICMP_NE, llvm::CmpInst::ICMP_SGE, llvm::CmpInst::ICMP_SGT, llvm::CmpInst::ICMP_SLE, llvm::CmpInst::ICMP_SLT, llvm::CmpInst::ICMP_UGE, llvm::CmpInst::ICMP_UGT, llvm::CmpInst::ICMP_ULE, llvm::CmpInst::ICMP_ULT, llvm::SmallPtrSetImpl< PtrType >::insert(), llvm::SCEV::isAllOnesValue(), llvm::BranchInst::isConditional(), llvm::ICmpInst::isEquality(), llvm::isGuardAsWidenableBranch(), llvm::ScalarEvolution::isKnownPredicate(), llvm::SCEV::isOne(), LatchExitProbabilityScale, LLVM_DEBUG, llvm::PatternMatch::m_And(), llvm::PatternMatch::m_Value(), llvm::PatternMatch::match(), llvm::None, llvm::SmallVectorImpl< T >::pop_back_val(), llvm::SmallVectorTemplateBase< T >::push_back(), llvm::SmallVectorTemplateBase< T, bool >::push_back(), llvm::RecursivelyDeleteTriviallyDeadInstructions(), llvm::BranchInst::setCondition(), llvm::User::setOperand(), llvm::SmallVectorBase< SmallVectorSizeType< T > >::size(), and SkipProfitabilityChecks.

◆ 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

Referenced by generateLoopLatchCheck().

◆ EnableIVTruncation

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

◆ false

loop Loop false

Definition at line 351 of file LoopPredication.cpp.

◆ 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

Referenced by normalizePredicate().

◆ 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 351 of file LoopPredication.cpp.

◆ SkipProfitabilityChecks

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

Referenced by normalizePredicate().