[PATCH] D99424: [BasicAA] Be more careful with modulo ops on VariableGEPIndex.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Jun 10 03:56:47 PDT 2021


fhahn updated this revision to Diff 351122.
fhahn added a comment.



In D99424#2709964 <https://reviews.llvm.org/D99424#2709964>, @nikic wrote:

> Okay, I've finally gotten around to looking into this in more detail. Because thinking about this really fries my brain, I ended up modelling this in alive2 (hopefully correctly...)
>
> https://alive2.llvm.org/ce/z/HYBxGs This is the general case and shows that we only need nsw flags on the arithmetic, rather than both nuw and nsw. This makes sense, as all the arithmetic involved is signed.
>
> https://alive2.llvm.org/ce/z/qXicaB This shows that it is indeed safe to always take the power-of-2 portion of the scale, even if the arithmetic is not nsw.

Thanks for checking with Alive. I've updated the code now to just track the NSW flag for LinearExpression/VariableGEPIndex and added a power-of-2 check for the scale.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D99424

Files:
  llvm/include/llvm/Analysis/BasicAliasAnalysis.h
  llvm/lib/Analysis/BasicAliasAnalysis.cpp
  llvm/test/Analysis/BasicAA/gep-alias.ll
  llvm/test/Analysis/BasicAA/gep-modulo.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D99424.351122.patch
Type: text/x-patch
Size: 7433 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20210610/a573a998/attachment.bin>


More information about the llvm-commits mailing list