[PATCH] D49024: [Polly] [WIP] Introduce ShapeInfo into polly for sizes and strides.

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 1 14:50:39 PDT 2018


Meinersbur added a comment.

In https://reviews.llvm.org/D49024#1184317, @cs15btech11044 wrote:

> Suppose we are considering a 3-dimensional array named arr (Consider C language for now).
>  Does the offset/padding solution suggested in the previous comment model the situation where each dimension of the array has its range from 0 to some dimension size value and while accessing the array, we use some arithmetic along with the respective dimension index ( arr[i+1][2*j-1][3*k] for instance)?


In that case i1/i2/i3 would be those expressions (`i1=i+1`,`i2=2*j-1`,'i3=3*k'). What matters is that behavior is only defined if each subscript evaluates to something within the size (`0<=i1<n1`) for its dimension.

> Also could you please elaborate on how would the byte-based indexing be more beneficial than the index-based approach?

It would allow padding that is not a multiple of the element size. Take for instance the 24bit BMP image format. Each pixel takes 3 bytes, but each line must start at 4-byte boundaries. E.g. use a 3x5 image (`RGB`=color value, '.'=padding):

  RGBRGBRGBRGBRGB.
  RGBRGBRGBRGBRGB.
  RGBRGBRGBRGBRGB

Each line has 5*3=15 bytes. To start the next line at a 4-byte boundary, a single byte of padding is added (so each line effectively takes 16 bytes; called `getTypeAllocSize` in LLVM).


https://reviews.llvm.org/D49024





More information about the llvm-commits mailing list