mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 20:32:21 +00:00
[LoopAccesses] Make VectorizerParams global
As LAA is becoming a pass, we can no longer pass the params to its constructor. This changes the command line flags to have external storage. These can now be accessed both from LV and LAA. VectorizerParams is moved out of LoopAccessInfo in order to shorten the code to access it. This is part of the patchset that converts LoopAccessAnalysis into an actual analysis pass. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@229622 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
38a9ebb065
commit
eefec589e8
@ -60,6 +60,22 @@ public:
|
|||||||
const Loop *TheLoop);
|
const Loop *TheLoop);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// \brief Collection of parameters shared beetween the Loop Vectorizer and the
|
||||||
|
/// Loop Access Analysis.
|
||||||
|
struct VectorizerParams {
|
||||||
|
/// \brief Maximum SIMD width.
|
||||||
|
static const unsigned MaxVectorWidth;
|
||||||
|
|
||||||
|
/// \brief VF as overridden by the user.
|
||||||
|
static unsigned VectorizationFactor;
|
||||||
|
/// \brief Interleave factor as overridden by the user.
|
||||||
|
static unsigned VectorizationInterleave;
|
||||||
|
|
||||||
|
/// \\brief When performing memory disambiguation checks at runtime do not
|
||||||
|
/// make more than this number of comparisons.
|
||||||
|
static const unsigned RuntimeMemoryCheckThreshold;
|
||||||
|
};
|
||||||
|
|
||||||
/// \brief Drive the analysis of memory accesses in the loop
|
/// \brief Drive the analysis of memory accesses in the loop
|
||||||
///
|
///
|
||||||
/// This class is responsible for analyzing the memory accesses of a loop. It
|
/// This class is responsible for analyzing the memory accesses of a loop. It
|
||||||
@ -76,30 +92,6 @@ public:
|
|||||||
/// RuntimePointerCheck class.
|
/// RuntimePointerCheck class.
|
||||||
class LoopAccessInfo {
|
class LoopAccessInfo {
|
||||||
public:
|
public:
|
||||||
/// \brief Collection of parameters used from the vectorizer.
|
|
||||||
struct VectorizerParams {
|
|
||||||
/// \brief Maximum simd width.
|
|
||||||
unsigned MaxVectorWidth;
|
|
||||||
|
|
||||||
/// \brief VF as overridden by the user.
|
|
||||||
unsigned VectorizationFactor;
|
|
||||||
/// \brief Interleave factor as overridden by the user.
|
|
||||||
unsigned VectorizationInterleave;
|
|
||||||
|
|
||||||
/// \\brief When performing memory disambiguation checks at runtime do not
|
|
||||||
/// make more than this number of comparisons.
|
|
||||||
unsigned RuntimeMemoryCheckThreshold;
|
|
||||||
|
|
||||||
VectorizerParams(unsigned MaxVectorWidth,
|
|
||||||
unsigned VectorizationFactor,
|
|
||||||
unsigned VectorizationInterleave,
|
|
||||||
unsigned RuntimeMemoryCheckThreshold) :
|
|
||||||
MaxVectorWidth(MaxVectorWidth),
|
|
||||||
VectorizationFactor(VectorizationFactor),
|
|
||||||
VectorizationInterleave(VectorizationInterleave),
|
|
||||||
RuntimeMemoryCheckThreshold(RuntimeMemoryCheckThreshold) {}
|
|
||||||
};
|
|
||||||
|
|
||||||
/// This struct holds information about the memory runtime legality check that
|
/// This struct holds information about the memory runtime legality check that
|
||||||
/// a group of pointers do not overlap.
|
/// a group of pointers do not overlap.
|
||||||
struct RuntimePointerCheck {
|
struct RuntimePointerCheck {
|
||||||
@ -139,11 +131,9 @@ public:
|
|||||||
|
|
||||||
LoopAccessInfo(Function *F, Loop *L, ScalarEvolution *SE,
|
LoopAccessInfo(Function *F, Loop *L, ScalarEvolution *SE,
|
||||||
const DataLayout *DL, const TargetLibraryInfo *TLI,
|
const DataLayout *DL, const TargetLibraryInfo *TLI,
|
||||||
AliasAnalysis *AA, DominatorTree *DT,
|
AliasAnalysis *AA, DominatorTree *DT) :
|
||||||
const VectorizerParams &VectParams) :
|
|
||||||
TheFunction(F), TheLoop(L), SE(SE), DL(DL), TLI(TLI), AA(AA), DT(DT),
|
TheFunction(F), TheLoop(L), SE(SE), DL(DL), TLI(TLI), AA(AA), DT(DT),
|
||||||
NumLoads(0), NumStores(0), MaxSafeDepDistBytes(-1U),
|
NumLoads(0), NumStores(0), MaxSafeDepDistBytes(-1U) {}
|
||||||
VectParams(VectParams) {}
|
|
||||||
|
|
||||||
/// Return true we can analyze the memory accesses in the loop and there are
|
/// Return true we can analyze the memory accesses in the loop and there are
|
||||||
/// no memory dependence cycles. Replaces symbolic strides using Strides.
|
/// no memory dependence cycles. Replaces symbolic strides using Strides.
|
||||||
@ -187,9 +177,6 @@ private:
|
|||||||
unsigned NumStores;
|
unsigned NumStores;
|
||||||
|
|
||||||
unsigned MaxSafeDepDistBytes;
|
unsigned MaxSafeDepDistBytes;
|
||||||
|
|
||||||
/// \brief Vectorizer parameters used by the analysis.
|
|
||||||
VectorizerParams VectParams;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
Value *stripIntegerCast(Value *V);
|
Value *stripIntegerCast(Value *V);
|
||||||
|
@ -437,10 +437,9 @@ public:
|
|||||||
typedef PointerIntPair<Value *, 1, bool> MemAccessInfo;
|
typedef PointerIntPair<Value *, 1, bool> MemAccessInfo;
|
||||||
typedef SmallPtrSet<MemAccessInfo, 8> MemAccessInfoSet;
|
typedef SmallPtrSet<MemAccessInfo, 8> MemAccessInfoSet;
|
||||||
|
|
||||||
MemoryDepChecker(ScalarEvolution *Se, const DataLayout *Dl, const Loop *L,
|
MemoryDepChecker(ScalarEvolution *Se, const DataLayout *Dl, const Loop *L)
|
||||||
const LoopAccessInfo::VectorizerParams &VectParams)
|
|
||||||
: SE(Se), DL(Dl), InnermostLoop(L), AccessIdx(0),
|
: SE(Se), DL(Dl), InnermostLoop(L), AccessIdx(0),
|
||||||
ShouldRetryWithRuntimeCheck(false), VectParams(VectParams) {}
|
ShouldRetryWithRuntimeCheck(false) {}
|
||||||
|
|
||||||
/// \brief Register the location (instructions are given increasing numbers)
|
/// \brief Register the location (instructions are given increasing numbers)
|
||||||
/// of a write access.
|
/// of a write access.
|
||||||
@ -495,9 +494,6 @@ private:
|
|||||||
/// vectorize this loop with runtime checks.
|
/// vectorize this loop with runtime checks.
|
||||||
bool ShouldRetryWithRuntimeCheck;
|
bool ShouldRetryWithRuntimeCheck;
|
||||||
|
|
||||||
/// \brief Vectorizer parameters used by the analysis.
|
|
||||||
LoopAccessInfo::VectorizerParams VectParams;
|
|
||||||
|
|
||||||
/// \brief Check whether there is a plausible dependence between the two
|
/// \brief Check whether there is a plausible dependence between the two
|
||||||
/// accesses.
|
/// accesses.
|
||||||
///
|
///
|
||||||
@ -621,7 +617,8 @@ bool MemoryDepChecker::couldPreventStoreLoadForward(unsigned Distance,
|
|||||||
// Store-load forwarding distance.
|
// Store-load forwarding distance.
|
||||||
const unsigned NumCyclesForStoreLoadThroughMemory = 8*TypeByteSize;
|
const unsigned NumCyclesForStoreLoadThroughMemory = 8*TypeByteSize;
|
||||||
// Maximum vector factor.
|
// Maximum vector factor.
|
||||||
unsigned MaxVFWithoutSLForwardIssues = VectParams.MaxVectorWidth*TypeByteSize;
|
unsigned MaxVFWithoutSLForwardIssues =
|
||||||
|
VectorizerParams::MaxVectorWidth * TypeByteSize;
|
||||||
if(MaxSafeDepDistBytes < MaxVFWithoutSLForwardIssues)
|
if(MaxSafeDepDistBytes < MaxVFWithoutSLForwardIssues)
|
||||||
MaxVFWithoutSLForwardIssues = MaxSafeDepDistBytes;
|
MaxVFWithoutSLForwardIssues = MaxSafeDepDistBytes;
|
||||||
|
|
||||||
@ -640,7 +637,8 @@ bool MemoryDepChecker::couldPreventStoreLoadForward(unsigned Distance,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (MaxVFWithoutSLForwardIssues < MaxSafeDepDistBytes &&
|
if (MaxVFWithoutSLForwardIssues < MaxSafeDepDistBytes &&
|
||||||
MaxVFWithoutSLForwardIssues != VectParams.MaxVectorWidth*TypeByteSize)
|
MaxVFWithoutSLForwardIssues !=
|
||||||
|
VectorizerParams::MaxVectorWidth * TypeByteSize)
|
||||||
MaxSafeDepDistBytes = MaxVFWithoutSLForwardIssues;
|
MaxSafeDepDistBytes = MaxVFWithoutSLForwardIssues;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -745,10 +743,10 @@ bool MemoryDepChecker::isDependent(const MemAccessInfo &A, unsigned AIdx,
|
|||||||
unsigned Distance = (unsigned) Val.getZExtValue();
|
unsigned Distance = (unsigned) Val.getZExtValue();
|
||||||
|
|
||||||
// Bail out early if passed-in parameters make vectorization not feasible.
|
// Bail out early if passed-in parameters make vectorization not feasible.
|
||||||
unsigned ForcedFactor = (VectParams.VectorizationFactor ?
|
unsigned ForcedFactor = (VectorizerParams::VectorizationFactor ?
|
||||||
VectParams.VectorizationFactor : 1);
|
VectorizerParams::VectorizationFactor : 1);
|
||||||
unsigned ForcedUnroll = (VectParams.VectorizationInterleave ?
|
unsigned ForcedUnroll = (VectorizerParams::VectorizationInterleave ?
|
||||||
VectParams.VectorizationInterleave : 1);
|
VectorizerParams::VectorizationInterleave : 1);
|
||||||
|
|
||||||
// The distance must be bigger than the size needed for a vectorized version
|
// The distance must be bigger than the size needed for a vectorized version
|
||||||
// of the operation and the size of the vectorized operation must not be
|
// of the operation and the size of the vectorized operation must not be
|
||||||
@ -831,7 +829,7 @@ bool LoopAccessInfo::canVectorizeMemory(ValueToValueMap &Strides) {
|
|||||||
PtrRtCheck.Need = false;
|
PtrRtCheck.Need = false;
|
||||||
|
|
||||||
const bool IsAnnotatedParallel = TheLoop->isAnnotatedParallel();
|
const bool IsAnnotatedParallel = TheLoop->isAnnotatedParallel();
|
||||||
MemoryDepChecker DepChecker(SE, DL, TheLoop, VectParams);
|
MemoryDepChecker DepChecker(SE, DL, TheLoop);
|
||||||
|
|
||||||
// For each block.
|
// For each block.
|
||||||
for (Loop::block_iterator bb = TheLoop->block_begin(),
|
for (Loop::block_iterator bb = TheLoop->block_begin(),
|
||||||
@ -1000,7 +998,8 @@ bool LoopAccessInfo::canVectorizeMemory(ValueToValueMap &Strides) {
|
|||||||
|
|
||||||
// Check that we did not collect too many pointers or found an unsizeable
|
// Check that we did not collect too many pointers or found an unsizeable
|
||||||
// pointer.
|
// pointer.
|
||||||
if (!CanDoRT || NumComparisons > VectParams.RuntimeMemoryCheckThreshold) {
|
if (!CanDoRT ||
|
||||||
|
NumComparisons > VectorizerParams::RuntimeMemoryCheckThreshold) {
|
||||||
PtrRtCheck.reset();
|
PtrRtCheck.reset();
|
||||||
CanDoRT = false;
|
CanDoRT = false;
|
||||||
}
|
}
|
||||||
@ -1040,14 +1039,15 @@ bool LoopAccessInfo::canVectorizeMemory(ValueToValueMap &Strides) {
|
|||||||
TheLoop, Strides, true);
|
TheLoop, Strides, true);
|
||||||
// Check that we did not collect too many pointers or found an unsizeable
|
// Check that we did not collect too many pointers or found an unsizeable
|
||||||
// pointer.
|
// pointer.
|
||||||
if (!CanDoRT || NumComparisons > VectParams.RuntimeMemoryCheckThreshold) {
|
if (!CanDoRT ||
|
||||||
|
NumComparisons > VectorizerParams::RuntimeMemoryCheckThreshold) {
|
||||||
if (!CanDoRT && NumComparisons > 0)
|
if (!CanDoRT && NumComparisons > 0)
|
||||||
emitAnalysis(VectorizationReport()
|
emitAnalysis(VectorizationReport()
|
||||||
<< "cannot check memory dependencies at runtime");
|
<< "cannot check memory dependencies at runtime");
|
||||||
else
|
else
|
||||||
emitAnalysis(VectorizationReport()
|
emitAnalysis(VectorizationReport()
|
||||||
<< NumComparisons << " exceeds limit of "
|
<< NumComparisons << " exceeds limit of "
|
||||||
<< VectParams.RuntimeMemoryCheckThreshold
|
<< VectorizerParams::RuntimeMemoryCheckThreshold
|
||||||
<< " dependent memory operations checked at runtime");
|
<< " dependent memory operations checked at runtime");
|
||||||
DEBUG(dbgs() << "LV: Can't vectorize with memory checks\n");
|
DEBUG(dbgs() << "LV: Can't vectorize with memory checks\n");
|
||||||
PtrRtCheck.reset();
|
PtrRtCheck.reset();
|
||||||
|
@ -106,14 +106,19 @@ using namespace llvm::PatternMatch;
|
|||||||
STATISTIC(LoopsVectorized, "Number of loops vectorized");
|
STATISTIC(LoopsVectorized, "Number of loops vectorized");
|
||||||
STATISTIC(LoopsAnalyzed, "Number of loops analyzed for vectorization");
|
STATISTIC(LoopsAnalyzed, "Number of loops analyzed for vectorization");
|
||||||
|
|
||||||
static cl::opt<unsigned>
|
static cl::opt<unsigned, true>
|
||||||
VectorizationFactor("force-vector-width", cl::init(0), cl::Hidden,
|
VectorizationFactor("force-vector-width", cl::Hidden,
|
||||||
cl::desc("Sets the SIMD width. Zero is autoselect."));
|
cl::desc("Sets the SIMD width. Zero is autoselect."),
|
||||||
|
cl::location(VectorizerParams::VectorizationFactor));
|
||||||
|
unsigned VectorizerParams::VectorizationFactor = 0;
|
||||||
|
|
||||||
static cl::opt<unsigned>
|
static cl::opt<unsigned, true>
|
||||||
VectorizationInterleave("force-vector-interleave", cl::init(0), cl::Hidden,
|
VectorizationInterleave("force-vector-interleave", cl::Hidden,
|
||||||
cl::desc("Sets the vectorization interleave count. "
|
cl::desc("Sets the vectorization interleave count. "
|
||||||
"Zero is autoselect."));
|
"Zero is autoselect."),
|
||||||
|
cl::location(
|
||||||
|
VectorizerParams::VectorizationInterleave));
|
||||||
|
unsigned VectorizerParams::VectorizationInterleave = 0;
|
||||||
|
|
||||||
static cl::opt<bool>
|
static cl::opt<bool>
|
||||||
EnableIfConversion("enable-if-conversion", cl::init(true), cl::Hidden,
|
EnableIfConversion("enable-if-conversion", cl::init(true), cl::Hidden,
|
||||||
@ -147,10 +152,10 @@ static const unsigned TinyTripCountUnrollThreshold = 128;
|
|||||||
|
|
||||||
/// When performing memory disambiguation checks at runtime do not make more
|
/// When performing memory disambiguation checks at runtime do not make more
|
||||||
/// than this number of comparisons.
|
/// than this number of comparisons.
|
||||||
static const unsigned RuntimeMemoryCheckThreshold = 8;
|
const unsigned VectorizerParams::RuntimeMemoryCheckThreshold = 8;
|
||||||
|
|
||||||
/// Maximum simd width.
|
/// Maximum simd width.
|
||||||
static const unsigned MaxVectorWidth = 64;
|
const unsigned VectorizerParams::MaxVectorWidth = 64;
|
||||||
|
|
||||||
static cl::opt<unsigned> ForceTargetNumScalarRegs(
|
static cl::opt<unsigned> ForceTargetNumScalarRegs(
|
||||||
"force-target-num-scalar-regs", cl::init(0), cl::Hidden,
|
"force-target-num-scalar-regs", cl::init(0), cl::Hidden,
|
||||||
@ -551,10 +556,7 @@ public:
|
|||||||
: NumPredStores(0), TheLoop(L), SE(SE), DL(DL),
|
: NumPredStores(0), TheLoop(L), SE(SE), DL(DL),
|
||||||
TLI(TLI), TheFunction(F), TTI(TTI), Induction(nullptr),
|
TLI(TLI), TheFunction(F), TTI(TTI), Induction(nullptr),
|
||||||
WidestIndTy(nullptr),
|
WidestIndTy(nullptr),
|
||||||
LAI(F, L, SE, DL, TLI, AA, DT,
|
LAI(F, L, SE, DL, TLI, AA, DT),
|
||||||
LoopAccessInfo::VectorizerParams(
|
|
||||||
MaxVectorWidth, VectorizationFactor, VectorizationInterleave,
|
|
||||||
RuntimeMemoryCheckThreshold)),
|
|
||||||
HasFunNoNaNAttr(false) {}
|
HasFunNoNaNAttr(false) {}
|
||||||
|
|
||||||
/// This enum represents the kinds of reductions that we support.
|
/// This enum represents the kinds of reductions that we support.
|
||||||
@ -1019,7 +1021,7 @@ class LoopVectorizeHints {
|
|||||||
bool validate(unsigned Val) {
|
bool validate(unsigned Val) {
|
||||||
switch (Kind) {
|
switch (Kind) {
|
||||||
case HK_WIDTH:
|
case HK_WIDTH:
|
||||||
return isPowerOf2_32(Val) && Val <= MaxVectorWidth;
|
return isPowerOf2_32(Val) && Val <= VectorizerParams::MaxVectorWidth;
|
||||||
case HK_UNROLL:
|
case HK_UNROLL:
|
||||||
return isPowerOf2_32(Val) && Val <= MaxInterleaveFactor;
|
return isPowerOf2_32(Val) && Val <= MaxInterleaveFactor;
|
||||||
case HK_FORCE:
|
case HK_FORCE:
|
||||||
|
Loading…
Reference in New Issue
Block a user