[PATCH] D91027: [BasicAA] Generalize base offset modulus handling

Johannes Doerfert via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Mon Nov 9 07:43:30 PST 2020


jdoerfert added inline comments.


================
Comment at: llvm/lib/Analysis/BasicAliasAnalysis.cpp:1399
+        (GCD - ModOffset).uge(V1Size.getValue()))
       return NoAlias;
 
----------------
Maybe a comment above this to explain, I don't get the reasoning TBH.

Here is my idea of what is happening but it is not complete:
```
// X[0:N] is a vector of N+1 unknowns
GEP1 = GEP1BaseOffset + X[0:N] * GEP1.scale[0:N]
GCD = gcd(GEP1.scale[0], ..., GEP1.scale[N])
ModOffset = GEP1BaseOffset % GCD
// Every value of GEP1 looks like: GEP1 := Y * GCD + ModOffset
// and ModOffset < GCD.
Diff = GCD - ModOffset
if (ModOffset >=u V2Size  // I guess V2 fits in the size between Y * GCD and GEP1
 &&      Diff >=u V1Size  // this I don't understand.
  return NoAlias;
```


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D91027



More information about the llvm-commits mailing list