pass element size to delinearization

Instead of relying on the delinearization to infer the size of an element,
compute the element size from the base address type. This is a much more precise
way of computing the element size than before, as we would have mixed together
the size of an element with the strides of the innermost dimension.

llvm-svn: 209695
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index c45524c..84508a2 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -363,7 +363,7 @@
 
     // Second step: find array shape.
     SmallVector<const SCEV *, 4> Sizes;
-    SE->findArrayDimensions(Terms, Sizes);
+    SE->findArrayDimensions(Terms, Sizes, Context.ElementSize[BasePointer]);
 
     // Third step: compute the access functions for each subscript.
     for (const SCEVAddRecExpr *AF : Context.NonAffineAccesses[BasePointer]) {
@@ -422,6 +422,9 @@
       return invalid<ReportNonAffineAccess>(Context, /*Assert=*/true,
                                             AccessFunction);
 
+    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.