[PATCH] D48026: [ScopHelper] Provide support for recognising collective invariant loads

Philip Pfaffe via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 26 03:05:28 PDT 2018


philip.pfaffe added inline comments.


================
Comment at: lib/Support/ScopHelper.cpp:462
+    for (int Idx = 1; Idx < GepInst->getNumIndices(); Idx++) {
+      auto Val = GepInst->getOperand(Idx);
+      const SCEV *PtrSCEV = SE.getSCEVAtScope(Val, LoopCopy);
----------------
Don't use almost-always-auto please.


================
Comment at: lib/Support/ScopHelper.cpp:465
+
+      while (LoopCopy && R.contains(LoopCopy)) {
+        if (!SE.isLoopInvariant(PtrSCEV, LoopCopy)) {
----------------
No this doesn't work.

Consider this:
```
struct A {
int a[M][N];
}
struct A a[L];

for (int i = 0; i < N; ++i)
  for (int j = 0; j < M; ++i)
      for (int k = 0; k < L; ++k)
          a[k].a[j][i] = 8;
```

You can't make assumptions about the order of GEP indices wrt. surrounding loops.


Repository:
  rPLO Polly

https://reviews.llvm.org/D48026





More information about the llvm-commits mailing list