|
LLVM
3.7.0
|
#include "llvm/Transforms/Scalar.h"#include "llvm/ADT/SetVector.h"#include "llvm/Analysis/AssumptionCache.h"#include "llvm/Analysis/CodeMetrics.h"#include "llvm/Analysis/InstructionSimplify.h"#include "llvm/Analysis/LoopPass.h"#include "llvm/Analysis/ScalarEvolution.h"#include "llvm/Analysis/ScalarEvolutionExpressions.h"#include "llvm/Analysis/TargetTransformInfo.h"#include "llvm/IR/DataLayout.h"#include "llvm/IR/DiagnosticInfo.h"#include "llvm/IR/Dominators.h"#include "llvm/IR/InstVisitor.h"#include "llvm/IR/IntrinsicInst.h"#include "llvm/IR/Metadata.h"#include "llvm/Support/CommandLine.h"#include "llvm/Support/Debug.h"#include "llvm/Support/raw_ostream.h"#include "llvm/Transforms/Utils/UnrollLoop.h"#include <climits>Go to the source code of this file.
Macros | |
| #define | DEBUG_TYPE "loop-unroll" |
Functions | |
| Optional< EstimatedUnrollCost > | analyzeLoopUnrollCost (const Loop *L, unsigned TripCount, ScalarEvolution &SE, const TargetTransformInfo &TTI, unsigned MaxUnrolledLoopSize) |
| Figure out if the loop is worth full unrolling. More... | |
| static unsigned | ApproximateLoopSize (const Loop *L, unsigned &NumCalls, bool &NotDuplicatable, const TargetTransformInfo &TTI, AssumptionCache *AC) |
| ApproximateLoopSize - Approximate the size of the loop. More... | |
| static MDNode * | GetUnrollMetadataForLoop (const Loop *L, StringRef Name) |
| static bool | HasUnrollFullPragma (const Loop *L) |
| static bool | HasUnrollDisablePragma (const Loop *L) |
| static bool | HasRuntimeUnrollDisablePragma (const Loop *L) |
| static unsigned | UnrollCountPragmaValue (const Loop *L) |
| static void | SetLoopAlreadyUnrolled (Loop *L) |
Variables | |
| static cl::opt< unsigned > | UnrollThreshold ("unroll-threshold", cl::init(150), cl::Hidden, cl::desc("The baseline cost threshold for loop unrolling")) |
| static cl::opt< unsigned > | UnrollPercentDynamicCostSavedThreshold ("unroll-percent-dynamic-cost-saved-threshold", cl::init(20), cl::Hidden, cl::desc("The percentage of estimated dynamic cost which must be saved by ""unrolling to allow unrolling up to the max threshold.")) |
| static cl::opt< unsigned > | UnrollDynamicCostSavingsDiscount ("unroll-dynamic-cost-savings-discount", cl::init(2000), cl::Hidden, cl::desc("This is the amount discounted from the total unroll cost when ""the unrolled form has a high dynamic cost savings (triggered by ""the '-unroll-perecent-dynamic-cost-saved-threshold' flag).")) |
| static cl::opt< unsigned > | UnrollMaxIterationsCountToAnalyze ("unroll-max-iteration-count-to-analyze", cl::init(0), cl::Hidden, cl::desc("Don't allow loop unrolling to simulate more than this number of""iterations when checking full unroll profitability")) |
| static cl::opt< unsigned > | UnrollCount ("unroll-count", cl::init(0), cl::Hidden, cl::desc("Use this unroll count for all loops including those with ""unroll_count pragma values, for testing purposes")) |
| static cl::opt< bool > | UnrollAllowPartial ("unroll-allow-partial", cl::init(false), cl::Hidden, cl::desc("Allows loops to be partially unrolled until ""-unroll-threshold loop size is reached.")) |
| static cl::opt< bool > | UnrollRuntime ("unroll-runtime", cl::ZeroOrMore, cl::init(false), cl::Hidden, cl::desc("Unroll loops with run-time trip counts")) |
| static cl::opt< unsigned > | PragmaUnrollThreshold ("pragma-unroll-threshold", cl::init(16 *1024), cl::Hidden, cl::desc("Unrolled size limit for loops with an unroll(full) or ""unroll_count pragma.")) |
| #define DEBUG_TYPE "loop-unroll" |
Definition at line 38 of file LoopUnrollPass.cpp.
| Optional<EstimatedUnrollCost> analyzeLoopUnrollCost | ( | const Loop * | L, |
| unsigned | TripCount, | ||
| ScalarEvolution & | SE, | ||
| const TargetTransformInfo & | TTI, | ||
| unsigned | MaxUnrolledLoopSize | ||
| ) |
Figure out if the loop is worth full unrolling.
Complete loop unrolling can make some loads constant, and we need to know if that would expose any further optimization opportunities. This routine estimates this optimization. It computes cost of unrolled loop (UnrolledCost) and dynamic cost of the original loop (RolledDynamicCost). By dynamic cost we mean that we won't count costs of blocks that are known not to be executed (i.e. if we have a branch in the loop and we know that at the given iteration its condition would be resolved to true, we won't add up the cost of the 'false'-block).
Definition at line 468 of file LoopUnrollPass.cpp.
References llvm::DenseMapBase< DenseMap< KeyT, ValueT, KeyInfoT, BucketT >, KeyT, ValueT, KeyInfoT, BucketT >::clear(), llvm::SetVector< T, SmallVector< T, N >, SmallSet< T, N > >::clear(), llvm::LoopBase< N, M >::contains(), llvm::LoopBase< N, M >::getHeader(), llvm::TargetTransformInfo::getUserCost(), llvm::SetVector< T, SmallVector< T, N >, SmallSet< T, N > >::insert(), llvm::None, llvm::SetVector< T, SmallVector< T, N >, SmallSet< T, N > >::size(), llvm::successors(), and UnrollMaxIterationsCountToAnalyze.
|
static |
ApproximateLoopSize - Approximate the size of the loop.
Definition at line 545 of file LoopUnrollPass.cpp.
References llvm::CodeMetrics::analyzeBasicBlock(), llvm::LoopBase< N, M >::block_begin(), llvm::LoopBase< N, M >::block_end(), llvm::CodeMetrics::collectEphemeralValues(), I, Metrics, llvm::CodeMetrics::notDuplicatable, llvm::CodeMetrics::NumInlineCandidates, and llvm::CodeMetrics::NumInsts.
Definition at line 575 of file LoopUnrollPass.cpp.
References llvm::Loop::getLoopID(), and llvm::GetUnrollMetadata().
Referenced by HasRuntimeUnrollDisablePragma(), HasUnrollDisablePragma(), HasUnrollFullPragma(), and UnrollCountPragmaValue().
Definition at line 592 of file LoopUnrollPass.cpp.
References GetUnrollMetadataForLoop().
Definition at line 587 of file LoopUnrollPass.cpp.
References GetUnrollMetadataForLoop().
Definition at line 582 of file LoopUnrollPass.cpp.
References GetUnrollMetadataForLoop().
|
static |
Definition at line 615 of file LoopUnrollPass.cpp.
References llvm::dyn_cast(), llvm::MDString::get(), llvm::MDNode::get(), llvm::LoopBase< N, M >::getHeader(), llvm::Loop::getLoopID(), llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), llvm::MDString::getString(), llvm::SmallVectorTemplateBase< T, isPodLike< T >::value >::push_back(), llvm::MDNode::replaceOperandWith(), llvm::Loop::setLoopID(), and llvm::StringRef::startswith().
Definition at line 598 of file LoopUnrollPass.cpp.
References llvm::MDNode::getNumOperands(), llvm::MDNode::getOperand(), and GetUnrollMetadataForLoop().
|
static |
|
static |
|
static |
|
static |
|
static |
Referenced by analyzeLoopUnrollCost().
|
static |
|
static |
1.8.6