Check that the elements of an array have the same size
At the moment we assume that only elements of identical size are stored/loaded
to a certain base pointer. This patch adds logic to the scop detection to verify
this.
Differential Revision: http://reviews.llvm.org/D5329
llvm-svn: 217727
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index 5865f2a..ea1915d 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -433,6 +433,15 @@
AccessFunction = SE->getMinusSCEV(AccessFunction, BasePointer);
+ const SCEV *Size = SE->getElementSize(&Inst);
+ if (Context.ElementSize.count(BasePointer)) {
+ if (Context.ElementSize[BasePointer] != Size)
+ return invalid<ReportDifferentArrayElementSize>(Context, /*Assert=*/true,
+ &Inst, BaseValue);
+ } else {
+ Context.ElementSize[BasePointer] = Size;
+ }
+
if (AllowNonAffine) {
// Do not check whether AccessFunction is affine.
} else if (!isAffineExpr(&Context.CurRegion, AccessFunction, *SE,
@@ -443,9 +452,6 @@
return invalid<ReportNonAffineAccess>(Context, /*Assert=*/true,
AccessFunction, &Inst, BaseValue);
- const SCEV *ElementSize = SE->getElementSize(&Inst);
- Context.ElementSize[BasePointer] = ElementSize;
-
// Collect all non affine memory accesses, and check whether they are linear
// at the end of scop detection. That way we can delinearize all the memory
// accesses to the same array in a unique step.