[PATCH] D109527: [Delinearization] Delinearization of Array-of-Struct. Proof-of-Concept.

Michael Kruse via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 10 12:30:31 PDT 2021


Meinersbur added inline comments.


================
Comment at: llvm/lib/Analysis/Delinearization.cpp:498
+  } else {
+    AssumedEltType = PtrVal->getType()->getPointerElementType();
+  }
----------------
nikic wrote:
> This isn't compatible with opaque pointers. The access size needs to be determine exclusively based on load/store element type (using GEP type is inappropriate for this as well, even if it won't outright crash).
This is the fallback case, we could pass the actual load/store as another parameter instead, but wasn't necessary for this PoC.

The GEP type is/was useful information though, leaking some information of how data is accessed from the source code. However, in principle this information can also derived from recurrence in the SCEV. In the test case it is `(12 + (12 * %N))`, i.e. a multiple of 12, suggesting that to be the array element size.


================
Comment at: llvm/test/Analysis/Delinearization/array_of_struct.ll:1
+; RUN: opt < %s -analyze -enable-new-pm=0 -delinearize | FileCheck %s
+; RUN: opt < %s -passes='print<delinearization>' -disable-output 2>&1 | FileCheck %s
----------------
bmahjour wrote:
> Could we add the following as a motivating test case as well:
> 
> ```
> struct __attribute__((packed)) MyS {
>   float a;
>   double b;
>   char c;
> };
> 
> void foo(long long n, long long m, struct MyS f1[][n][m]) {
>   for (int i = 0; i < 1024; i++)
>     for (int j = 0; j < n; j++)
>       for (int k = 0; k < m; k++)
>         f1[i][j][k].b = f1[i-1][j][k].b;
> }
> ```
> 
> The expected delinearization would produce the same subscripts in every dimension (including the added inner-most byte dimension) except for the outer-most dimension where the absolute difference between the subscripts should be 1.
I will try to make this work.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D109527/new/

https://reviews.llvm.org/D109527



More information about the llvm-commits mailing list