|
LLVM
10.0.0
|
#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/ScalarEvolutionExpander.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"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 BranchInst * | FindWidenableTerminatorAboveLoop (Loop *L, LoopInfo &LI) |
| If we can (cheaply) find a widenable branch which controls entry into the loop, return it. More... | |
| static const SCEV * | getMinAnalyzeableBackedgeTakenCount (ScalarEvolution &SE, DominatorTree &DT, Loop *L) |
| Return the minimum of all analyzeable exit counts. More... | |
| static bool | isVeryLikelyToDeopt (BasicBlock *BB) |
| Return true if we can be fairly sure that executing block BB will probably lead to executing an __llvm_deoptimize. 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)) |
| loop | predication |
| loop Loop | false |
| #define DEBUG_TYPE "loop-predication" |
Definition at line 203 of file LoopPredication.cpp.
|
static |
If we can (cheaply) find a widenable branch which controls entry into the loop, return it.
Definition at line 968 of file LoopPredication.cpp.
References llvm::LoopBase< BlockT, LoopT >::getLoopPreheader(), llvm::BasicBlock::getSinglePredecessor(), llvm::BasicBlock::getSingleSuccessor(), and llvm::BasicBlock::getTerminator().
Referenced by isVeryLikelyToDeopt().
|
static |
Definition at line 470 of file LoopPredication.cpp.
References llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::dbgs(), llvm::dyn_cast(), EnableCountDownLoop, llvm::CmpInst::getFlippedStrictnessPredicate(), llvm::ScalarEvolution::getTruncateExpr(), llvm::DataLayout::getTypeSizeInBits(), llvm::Loop::hasLoopInvariantOperands(), llvm::CmpInst::ICMP_ULT, llvm::SCEV::isAllOnesValue(), llvm::Loop::isLoopInvariant(), llvm::SCEV::isOne(), llvm::isSafeToExpandAt(), isSafeToTruncateWideIVType(), LLVM_DEBUG, and llvm::None.
Referenced by normalizePredicate().
|
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 1002 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(), llvm::ScalarEvolution::getUMinFromMismatchedTypes(), llvm::SmallVectorTemplateBase< T >::push_back(), and llvm::SmallVectorBase::size().
| INITIALIZE_PASS_BEGIN | ( | LoopPredicationLegacyPass | , |
| "loop-predication" | , | ||
| "Loop predication" | , | ||
| false | , | ||
| false | |||
| ) |
|
static |
Definition at line 435 of file LoopPredication.cpp.
References assert(), llvm::dyn_cast(), EnableIVTruncation, and llvm::DataLayout::getTypeSizeInBits().
Referenced by generateLoopLatchCheck().
|
static |
Return true if we can be fairly sure that executing block BB will probably lead to executing an __llvm_deoptimize.
This is a profitability heuristic, not a legality constraint.
Definition at line 1026 of file LoopPredication.cpp.
References llvm::dyn_cast(), llvm::SmallVectorBase::empty(), FindWidenableTerminatorAboveLoop(), llvm::LoopBase< BlockT, LoopT >::getExitingBlocks(), llvm::LoopBase< BlockT, LoopT >::getLoopLatch(), llvm::BasicBlock::getTerminatingDeoptimizeCall(), llvm::BasicBlock::getUniqueSuccessor(), and Rewriter.
|
static |
Definition at line 658 of file LoopPredication.cpp.
References assert(), llvm::IRBuilder< T, Inserter >::CreateAnd(), llvm::dbgs(), llvm::Value::dump(), llvm::dyn_cast(), llvm::SmallVectorBase::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::size(), and SkipProfitabilityChecks.
| STATISTIC | ( | TotalConsidered | , |
| "Number of guards considered" | |||
| ) |
| STATISTIC | ( | TotalWidened | , |
| "Number of checks widened" | |||
| ) |
|
static |
Referenced by generateLoopLatchCheck().
|
static |
Referenced by isSafeToTruncateWideIVType().
| loop Loop false |
Definition at line 351 of file LoopPredication.cpp.
|
static |
Referenced by normalizePredicate().
|
static |
| loop Loop predication |
Definition at line 351 of file LoopPredication.cpp.
|
static |
Referenced by normalizePredicate().
1.8.13