[PATCH] D59065: [BasicAA] Simplify inttoptr(and(ptrtoint(X), C)) to X, if C preserves all significant bits.

Florian Hahn via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 29 15:19:27 PDT 2019


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

In D59065#1448178 <https://reviews.llvm.org/D59065#1448178>, @hfinkel wrote:

> > I am also not entirely sure how control dependencies could add new underlying objects with this patch
>
> Please read this https://bugs.llvm.org/show_bug.cgi?id=34548


This was very helpful and interesting, thanks!

> I *think* that this is okay if the ptrtoint and the and have only one user, and they're in the same basic block, and there's nothing that can throw, etc. in between?

Thanks, from the reading above, those restrictions should prevent applying the
analysis on ptrtoint/inttoptr pairs where multiple objects contribute to the result.

I've updated the patch to check the number of users and to not allow any instructions between ptrtoint,and,inttoptr for now. We can relax that later IMO.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D59065

Files:
  llvm/include/llvm/Analysis/ValueTracking.h
  llvm/include/llvm/IR/DataLayout.h
  llvm/include/llvm/IR/PatternMatch.h
  llvm/lib/Analysis/BasicAliasAnalysis.cpp
  llvm/lib/Analysis/ValueTracking.cpp
  llvm/lib/IR/DataLayout.cpp
  llvm/test/Analysis/BasicAA/strip-nonsignificant-ptr-bits.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D59065.192931.patch
Type: text/x-patch
Size: 14247 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20190329/68dffb5f/attachment.bin>


More information about the llvm-commits mailing list