[PATCH] D109746: [AA] Teach BasicAA to recognize basic GEP range information.

Clement Courbet via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Sep 17 02:33:33 PDT 2021


courbet added inline comments.


================
Comment at: llvm/lib/Analysis/BasicAliasAnalysis.cpp:1243
+          MaxVarIndex =
+              Var.Scale.abs() * MaxV.sextOrTrunc(Var.Scale.getBitWidth());
+        }
----------------
nikic wrote:
> Can't you use the ConstantRange API to perform the multiplication by the scale?
> 
> Also, we need to consider overflow here. If the NSW flag is set we can exclude overflow and perform a saturating multiplication, but otherwise we need to take it into account, and this is not just a matter of multiplying the bounds. ConstantRange should do that correctly, though conservatively. We should have tests for this as well.
Thanks for the suggestion. In addition to correctness, that actually makes the code much simpler too.

I've added a bunch of tests that exercise various edge cases.





Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D109746



More information about the llvm-commits mailing list