[PATCH] D89456: [SCEV] Introduce SCEVPtrToIntExpr (PR46786)

Roman Lebedev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Thu Oct 15 03:57:21 PDT 2020


lebedev.ri created this revision.
lebedev.ri added reviewers: efriedma, mkazantsev.
lebedev.ri added a project: LLVM.
Herald added a reviewer: bollu.
Herald added subscribers: javed.absar, hiraditya.
lebedev.ri requested review of this revision.

And use it to model LLVM IR's `ptrtoint` cast.

As we've established by now, there are at least two reasons why we want this:

- It will allow SCEV to be aware of `ptrtoint` casts, instead of treating them as `SCEVUnknown`
- It should

As discussed in PR46786 <https://bugs.llvm.org/show_bug.cgi?id=46786>, in principle,
we could just extend `SCEVUnknown` with a `is ptrtoint` cast, because `ScalarEvolution::getPtrToIntExpr()`
should sink the cast as far down into the expression as possible,
so in the end we should always end up with `SCEVPtrToIntExpr` of `SCEVUnknown`.

But i think that it doesn't really matter from memory consumption side - there probably
won't be *that* many `SCEVPtrToIntExpr`s for it to matter, and it allows for much better
discoverability.

This probably needs some more tests.
I'm not adding any rewrites right in this patch.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D89456

Files:
  llvm/include/llvm/Analysis/ScalarEvolution.h
  llvm/include/llvm/Analysis/ScalarEvolutionDivision.h
  llvm/include/llvm/Analysis/ScalarEvolutionExpressions.h
  llvm/include/llvm/Transforms/Utils/ScalarEvolutionExpander.h
  llvm/lib/Analysis/ScalarEvolution.cpp
  llvm/lib/Transforms/Utils/ScalarEvolutionExpander.cpp
  llvm/test/Analysis/ScalarEvolution/add-expr-pointer-operand-sorting.ll
  llvm/test/Analysis/ScalarEvolution/no-wrap-add-exprs.ll
  llvm/test/Analysis/ScalarEvolution/ptrtoint-constantexpr-loop.ll
  llvm/test/Analysis/ScalarEvolution/ptrtoint.ll
  llvm/test/Other/constant-fold-gep.ll
  llvm/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll
  polly/include/polly/Support/SCEVAffinator.h
  polly/lib/Support/SCEVAffinator.cpp
  polly/lib/Support/SCEVValidator.cpp
  polly/lib/Support/ScopHelper.cpp
  polly/test/Isl/CodeGen/ptrtoint_as_parameter.ll
  polly/test/ScopInfo/int2ptr_ptr2int.ll
  polly/test/ScopInfo/int2ptr_ptr2int_2.ll

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D89456.298342.patch
Type: text/x-patch
Size: 71281 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20201015/c639b8e4/attachment.bin>


More information about the llvm-commits mailing list