[polly] r259522 - ScopInfo: Split memory access construction into different cases
Tobias Grosser via llvm-commits
llvm-commits at lists.llvm.org
Tue Feb 2 08:46:49 PST 2016
Author: grosser
Date: Tue Feb 2 10:46:49 2016
New Revision: 259522
URL: http://llvm.org/viewvc/llvm-project?rev=259522&view=rev
Log:
ScopInfo: Split memory access construction into different cases
We create separate functions for fixed-size multi-dimensional, parameteric-sized
multi-dimensional, as well as single-dimensional memory accesses to reduce the
complexity of a large monolithic function.
Suggested-by: Michael Kruse <llvm at meinersbur.de>
Modified:
polly/trunk/include/polly/ScopInfo.h
polly/trunk/lib/Analysis/ScopInfo.cpp
Modified: polly/trunk/include/polly/ScopInfo.h
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/include/polly/ScopInfo.h?rev=259522&r1=259521&r2=259522&view=diff
==============================================================================
--- polly/trunk/include/polly/ScopInfo.h (original)
+++ polly/trunk/include/polly/ScopInfo.h Tue Feb 2 10:46:49 2016
@@ -1931,6 +1931,46 @@ class ScopInfo : public RegionPass {
// Build the SCoP for Region @p R.
void buildScop(Region &R, AssumptionCache &AC);
+ /// @brief Try to build a multi-dimensional fixed sized MemoryAccess from
+ /// the Load/Store instruction.
+ ///
+ /// @param Inst The Load/Store instruction that access the memory
+ /// @param L The parent loop of the instruction
+ /// @param R The region on which to build the data access dictionary.
+ /// @param BoxedLoops The set of loops that are overapproximated in @p R.
+ /// @param ScopRIL The required invariant loads equivalence classes.
+ /// @returns True if the access could be built, False otherwise.
+ bool
+ buildAccessMultiDimFixed(MemAccInst Inst, Loop *L, Region *R,
+ const ScopDetection::BoxedLoopsSetTy *BoxedLoops,
+ const InvariantLoadsSetTy &ScopRIL);
+
+ /// @brief Try to build a multi-dimensional parameteric sized MemoryAccess
+ /// from the Load/Store instruction.
+ ///
+ /// @param Inst The Load/Store instruction that access the memory
+ /// @param L The parent loop of the instruction
+ /// @param R The region on which to build the data access dictionary.
+ /// @param BoxedLoops The set of loops that are overapproximated in @p R.
+ /// @param ScopRIL The required invariant loads equivalence classes.
+ /// @returns True if the access could be built, False otherwise.
+ bool
+ buildAccessMultiDimParam(MemAccInst Inst, Loop *L, Region *R,
+ const ScopDetection::BoxedLoopsSetTy *BoxedLoops,
+ const InvariantLoadsSetTy &ScopRIL);
+
+ /// @brief Build a single-dimensional parameteric sized MemoryAccess
+ /// from the Load/Store instruction.
+ ///
+ /// @param Inst The Load/Store instruction that access the memory
+ /// @param L The parent loop of the instruction
+ /// @param R The region on which to build the data access dictionary.
+ /// @param BoxedLoops The set of loops that are overapproximated in @p R.
+ /// @param ScopRIL The required invariant loads equivalence classes.
+ void buildAccessSingleDim(MemAccInst Inst, Loop *L, Region *R,
+ const ScopDetection::BoxedLoopsSetTy *BoxedLoops,
+ const InvariantLoadsSetTy &ScopRIL);
+
/// @brief Build an instance of MemoryAccess from the Load/Store instruction.
///
/// @param Inst The Load/Store instruction that access the memory
Modified: polly/trunk/lib/Analysis/ScopInfo.cpp
URL: http://llvm.org/viewvc/llvm-project/polly/trunk/lib/Analysis/ScopInfo.cpp?rev=259522&r1=259521&r2=259522&view=diff
==============================================================================
--- polly/trunk/lib/Analysis/ScopInfo.cpp (original)
+++ polly/trunk/lib/Analysis/ScopInfo.cpp Tue Feb 2 10:46:49 2016
@@ -3756,24 +3756,19 @@ bool ScopInfo::buildScalarDependences(In
extern MapInsnToMemAcc InsnToMemAcc;
-void ScopInfo::buildMemoryAccess(
+bool ScopInfo::buildAccessMultiDimFixed(
MemAccInst Inst, Loop *L, Region *R,
const ScopDetection::BoxedLoopsSetTy *BoxedLoops,
const InvariantLoadsSetTy &ScopRIL) {
-
- Value *Address = Inst.getPointerOperand();
Value *Val = Inst.getValueOperand();
Type *SizeType = Val->getType();
unsigned ElementSize = DL->getTypeAllocSize(SizeType);
- enum MemoryAccess::AccessType Type =
- Inst.isLoad() ? MemoryAccess::READ : MemoryAccess::MUST_WRITE;
-
+ Value *Address = Inst.getPointerOperand();
const SCEV *AccessFunction = SE->getSCEVAtScope(Address, L);
const SCEVUnknown *BasePointer =
dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFunction));
-
- assert(BasePointer && "Could not find base pointer");
- AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
+ enum MemoryAccess::AccessType Type =
+ Inst.isLoad() ? MemoryAccess::READ : MemoryAccess::MUST_WRITE;
if (isa<GetElementPtrInst>(Address) || isa<BitCastInst>(Address)) {
auto NewAddress = Address;
@@ -3793,31 +3788,47 @@ void ScopInfo::buildMemoryAccess(
std::vector<const SCEV *> SizesSCEV;
- bool AllAffineSubcripts = true;
for (auto Subscript : Subscripts) {
InvariantLoadsSetTy AccessILS;
- AllAffineSubcripts =
- isAffineExpr(R, Subscript, *SE, nullptr, &AccessILS);
+ if (!isAffineExpr(R, Subscript, *SE, nullptr, &AccessILS))
+ return false;
for (LoadInst *LInst : AccessILS)
if (!ScopRIL.count(LInst))
- AllAffineSubcripts = false;
-
- if (!AllAffineSubcripts)
- break;
+ return false;
}
- if (AllAffineSubcripts && Sizes.size() > 0) {
+ if (Sizes.size() > 0) {
for (auto V : Sizes)
SizesSCEV.push_back(SE->getSCEV(ConstantInt::get(
IntegerType::getInt64Ty(BasePtr->getContext()), V)));
addArrayAccess(Inst, Type, BasePointer->getValue(), ElementSize, true,
Subscripts, SizesSCEV, Val);
- return;
+ return true;
}
}
}
+ return false;
+}
+
+bool ScopInfo::buildAccessMultiDimParam(
+ MemAccInst Inst, Loop *L, Region *R,
+ const ScopDetection::BoxedLoopsSetTy *BoxedLoops,
+ const InvariantLoadsSetTy &ScopRIL) {
+ Value *Address = Inst.getPointerOperand();
+ Value *Val = Inst.getValueOperand();
+ Type *SizeType = Val->getType();
+ unsigned ElementSize = DL->getTypeAllocSize(SizeType);
+ enum MemoryAccess::AccessType Type =
+ Inst.isLoad() ? MemoryAccess::READ : MemoryAccess::MUST_WRITE;
+
+ const SCEV *AccessFunction = SE->getSCEVAtScope(Address, L);
+ const SCEVUnknown *BasePointer =
+ dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFunction));
+
+ assert(BasePointer && "Could not find base pointer");
+ AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
auto AccItr = InsnToMemAcc.find(Inst);
if (PollyDelinearize && AccItr != InsnToMemAcc.end()) {
@@ -3832,8 +3843,28 @@ void ScopInfo::buildMemoryAccess(
addArrayAccess(Inst, Type, BasePointer->getValue(), ElementSize, true,
AccItr->second.DelinearizedSubscripts, Sizes, Val);
- return;
+ return true;
}
+ return false;
+}
+
+void ScopInfo::buildAccessSingleDim(
+ MemAccInst Inst, Loop *L, Region *R,
+ const ScopDetection::BoxedLoopsSetTy *BoxedLoops,
+ const InvariantLoadsSetTy &ScopRIL) {
+ Value *Address = Inst.getPointerOperand();
+ Value *Val = Inst.getValueOperand();
+ Type *SizeType = Val->getType();
+ unsigned ElementSize = DL->getTypeAllocSize(SizeType);
+ enum MemoryAccess::AccessType Type =
+ Inst.isLoad() ? MemoryAccess::READ : MemoryAccess::MUST_WRITE;
+
+ const SCEV *AccessFunction = SE->getSCEVAtScope(Address, L);
+ const SCEVUnknown *BasePointer =
+ dyn_cast<SCEVUnknown>(SE->getPointerBase(AccessFunction));
+
+ assert(BasePointer && "Could not find base pointer");
+ AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
// Check if the access depends on a loop contained in a non-affine subregion.
bool isVariantInNonAffineLoop = false;
@@ -3861,6 +3892,20 @@ void ScopInfo::buildMemoryAccess(
{AccessFunction}, {}, Val);
}
+void ScopInfo::buildMemoryAccess(
+ MemAccInst Inst, Loop *L, Region *R,
+ const ScopDetection::BoxedLoopsSetTy *BoxedLoops,
+ const InvariantLoadsSetTy &ScopRIL) {
+
+ if (buildAccessMultiDimFixed(Inst, L, R, BoxedLoops, ScopRIL))
+ return;
+
+ if (buildAccessMultiDimParam(Inst, L, R, BoxedLoops, ScopRIL))
+ return;
+
+ buildAccessSingleDim(Inst, L, R, BoxedLoops, ScopRIL);
+}
+
void ScopInfo::buildAccessFunctions(Region &R, Region &SR) {
if (SD->isNonAffineSubRegion(&SR, &R)) {
More information about the llvm-commits
mailing list