typedef std::vector<const SCEVAddRecExpr *> AFs;
typedef std::map<const SCEVUnknown *, AFs> BaseToAFs;
+typedef std::map<const SCEVUnknown *, const SCEV *> BaseToElSize;
extern bool PollyTrackFailures;
extern bool PollyDelinearize;
// Map a base pointer to all access functions accessing it.
BaseToAFs NonAffineAccesses, AffineAccesses;
+ BaseToElSize ElementSize;
DetectionContext(Region &R, AliasAnalysis &AA, bool Verify)
: CurRegion(R), AST(AA), Verifying(Verify), Log(&R) {}
// 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]) {
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.
const SCEVAddRecExpr *AF = dyn_cast<SCEVAddRecExpr>(AccessFunction);
if (!IsAffine && PollyDelinearize && AF) {
- const SCEV *Remainder = AF->delinearize(*SE, Subscripts, Sizes);
+ const SCEV *ElementSize = SE->getElementSize(Inst);
+ const SCEV *Remainder =
+ AF->delinearize(*SE, Subscripts, Sizes, ElementSize);
int NSubs = Subscripts.size();
if (NSubs > 0) {