diff options
author | Adam Nemet <anemet@apple.com> | 2016-06-17 22:35:41 +0000 |
---|---|---|
committer | Adam Nemet <anemet@apple.com> | 2016-06-17 22:35:41 +0000 |
commit | a9f09c6245b9078d0719e0fd9d2aba60b39dd3ac (patch) | |
tree | d0559b1347ce05c36e2b100484bbfc9b4b759110 /llvm/lib | |
parent | fb72718ebf530f566d82d468619506fed3056671 (diff) | |
download | bcm5719-llvm-a9f09c6245b9078d0719e0fd9d2aba60b39dd3ac.tar.gz bcm5719-llvm-a9f09c6245b9078d0719e0fd9d2aba60b39dd3ac.zip |
[LAA] Enable symbolic stride speculation for all LAA clients
This is a functional change for LLE and LDist. The other clients (LV,
LVerLICM) already had this explicitly enabled.
The temporary boolean parameter to LAA is removed that allowed turning
off speculation of symbolic strides. This makes LAA's caching interface
LAA::getInfo only take the loop as the parameter. This makes the
interface more friendly to the new Pass Manager.
The flag -enable-mem-access-versioning is moved from LV to a LAA which
now allows turning off speculation globally.
llvm-svn: 273064
Diffstat (limited to 'llvm/lib')
-rw-r--r-- | llvm/lib/Analysis/LoopAccessAnalysis.cpp | 38 | ||||
-rw-r--r-- | llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp | 2 | ||||
-rw-r--r-- | llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | 17 |
3 files changed, 24 insertions, 33 deletions
diff --git a/llvm/lib/Analysis/LoopAccessAnalysis.cpp b/llvm/lib/Analysis/LoopAccessAnalysis.cpp index 69e7ce49cb6..44208408b0f 100644 --- a/llvm/lib/Analysis/LoopAccessAnalysis.cpp +++ b/llvm/lib/Analysis/LoopAccessAnalysis.cpp @@ -65,6 +65,21 @@ static cl::opt<unsigned> "loop-access analysis (default = 100)"), cl::init(100)); +/// This enables versioning on the strides of symbolically striding memory +/// accesses in code like the following. +/// for (i = 0; i < N; ++i) +/// A[i * Stride1] += B[i * Stride2] ... +/// +/// Will be roughly translated to +/// if (Stride1 == 1 && Stride2 == 1) { +/// for (i = 0; i < N; i+=4) +/// A[i:i+3] += ... +/// } else +/// ... +static cl::opt<bool> EnableMemAccessVersioning( + "enable-mem-access-versioning", cl::init(true), cl::Hidden, + cl::desc("Enable symbolic stride memory access versioning")); + /// \brief Enable store-to-load forwarding conflict detection. This option can /// be disabled for correctness testing. static cl::opt<bool> EnableForwardingConflictDetection( @@ -1540,7 +1555,7 @@ void LoopAccessInfo::analyzeLoop() { NumLoads++; Loads.push_back(Ld); DepChecker.addAccess(Ld); - if (SpeculateSymbolicStrides) + if (EnableMemAccessVersioning) collectStridedAccess(Ld); continue; } @@ -1564,7 +1579,7 @@ void LoopAccessInfo::analyzeLoop() { NumStores++; Stores.push_back(St); DepChecker.addAccess(St); - if (SpeculateSymbolicStrides) + if (EnableMemAccessVersioning) collectStridedAccess(St); } } // Next instr. @@ -1904,11 +1919,9 @@ void LoopAccessInfo::collectStridedAccess(Value *MemAccess) { LoopAccessInfo::LoopAccessInfo(Loop *L, ScalarEvolution *SE, const DataLayout &DL, const TargetLibraryInfo *TLI, AliasAnalysis *AA, - DominatorTree *DT, LoopInfo *LI, - bool SpeculateSymbolicStrides) - : SpeculateSymbolicStrides(SpeculateSymbolicStrides), PSE(*SE, *L), - PtrRtChecking(SE), DepChecker(PSE, L), TheLoop(L), DL(DL), TLI(TLI), - AA(AA), DT(DT), LI(LI), NumLoads(0), NumStores(0), + DominatorTree *DT, LoopInfo *LI) + : PSE(*SE, *L), PtrRtChecking(SE), DepChecker(PSE, L), TheLoop(L), DL(DL), + TLI(TLI), AA(AA), DT(DT), LI(LI), NumLoads(0), NumStores(0), MaxSafeDepDistBytes(-1U), CanVecMem(false), StoreToLoopInvariantAddress(false) { if (canAnalyzeLoop()) @@ -1955,19 +1968,12 @@ void LoopAccessInfo::print(raw_ostream &OS, unsigned Depth) const { PSE.print(OS, Depth); } -const LoopAccessInfo & -LoopAccessAnalysis::getInfo(Loop *L, bool SpeculateSymbolicStrides) { +const LoopAccessInfo &LoopAccessAnalysis::getInfo(Loop *L) { auto &LAI = LoopAccessInfoMap[L]; -#ifndef NDEBUG - assert((!LAI || LAI->SpeculateSymbolicStrides == SpeculateSymbolicStrides) && - "Symbolic strides changed for loop"); -#endif - if (!LAI) { const DataLayout &DL = L->getHeader()->getModule()->getDataLayout(); - LAI = llvm::make_unique<LoopAccessInfo>(L, SE, DL, TLI, AA, DT, LI, - SpeculateSymbolicStrides); + LAI = llvm::make_unique<LoopAccessInfo>(L, SE, DL, TLI, AA, DT, LI); } return *LAI.get(); } diff --git a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp index 3ac01a75892..b88ca7e717d 100644 --- a/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp +++ b/llvm/lib/Transforms/Scalar/LoopVersioningLICM.cpp @@ -385,7 +385,7 @@ bool LoopVersioningLICM::legalLoopInstructions() { return false; } // Get LoopAccessInfo from current loop. - LAI = &LAA->getInfo(CurLoop, true); + LAI = &LAA->getInfo(CurLoop); // Check LoopAccessInfo for need of runtime check. if (LAI->getRuntimePointerChecking()->getChecks().empty()) { DEBUG(dbgs() << " LAA: Runtime check not found !!\n"); diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp index 0c4605ea4b3..954b5938cf5 100644 --- a/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp +++ b/llvm/lib/Transforms/Vectorize/LoopVectorize.cpp @@ -130,21 +130,6 @@ static cl::opt<bool> MaximizeBandwidth( cl::desc("Maximize bandwidth when selecting vectorization factor which " "will be determined by the smallest type in loop.")); -/// This enables versioning on the strides of symbolically striding memory -/// accesses in code like the following. -/// for (i = 0; i < N; ++i) -/// A[i * Stride1] += B[i * Stride2] ... -/// -/// Will be roughly translated to -/// if (Stride1 == 1 && Stride2 == 1) { -/// for (i = 0; i < N; i+=4) -/// A[i:i+3] += ... -/// } else -/// ... -static cl::opt<bool> EnableMemAccessVersioning( - "enable-mem-access-versioning", cl::init(true), cl::Hidden, - cl::desc("Enable symbolic stride memory access versioning")); - static cl::opt<bool> EnableInterleavedMemAccesses( "enable-interleaved-mem-accesses", cl::init(false), cl::Hidden, cl::desc("Enable vectorization on interleaved memory accesses in a loop")); @@ -4970,7 +4955,7 @@ void LoopVectorizationLegality::collectLoopUniforms() { } bool LoopVectorizationLegality::canVectorizeMemory() { - LAI = &LAA->getInfo(TheLoop, EnableMemAccessVersioning); + LAI = &LAA->getInfo(TheLoop); auto &OptionalReport = LAI->getReport(); if (OptionalReport) emitAnalysis(VectorizationReport(*OptionalReport)); |