[all-commits] [llvm/llvm-project] 81fc53: [SCEV] Introduce SCEVPtrToIntExpr (PR46786)

Roman Lebedev via All-commits all-commits at lists.llvm.org
Fri Oct 30 01:14:15 PDT 2020


  Branch: refs/heads/master
  Home:   https://github.com/llvm/llvm-project
  Commit: 81fc53a36a4e3ca5cc9d5bc9b3ea32f304e35b93
      https://github.com/llvm/llvm-project/commit/81fc53a36a4e3ca5cc9d5bc9b3ea32f304e35b93
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-10-30 (Fri, 30 Oct 2020)

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

  Log Message:
  -----------
  [SCEV] Introduce SCEVPtrToIntExpr (PR46786)

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

This is essentially an alternative to D88806, but with no chance for
all the problems it caused due to having the cast as implicit there.
(see rG7ee6c402474a2f5fd21c403e7529f97f6362fdb3)

As we've established by now, there are at least two reasons why we want this:
* It will allow SCEV to actually model the `ptrtoint` casts
  and their operands, instead of treating them as `SCEVUnknown`
* It should help with initial problem of PR46786 - this should eventually allow us
  to not loose pointer-ness of an expression in more cases

As discussed in [[ https://bugs.llvm.org/show_bug.cgi?id=46786 | PR46786 ]], 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 isn't the best solution, because 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.

Reviewed By: mkazantsev

Differential Revision: https://reviews.llvm.org/D89456


  Commit: b4916918e5219ac25a5b6472c5638450f867d975
      https://github.com/llvm/llvm-project/commit/b4916918e5219ac25a5b6472c5638450f867d975
  Author: Roman Lebedev <lebedev.ri at gmail.com>
  Date:   2020-10-30 (Fri, 30 Oct 2020)

  Changed paths:
    M llvm/lib/Analysis/ScalarEvolution.cpp
    M llvm/test/Analysis/ScalarEvolution/ptrtoint.ll
    M llvm/test/Transforms/LoopStrengthReduce/X86/expander-crashes.ll
    M polly/test/ScopInfo/int2ptr_ptr2int.ll
    M polly/test/ScopInfo/int2ptr_ptr2int_2.ll

  Log Message:
  -----------
  [SCEV] SCEVPtrToIntExpr simplifications

If we've got an SCEVPtrToIntExpr(op), where op is not an SCEVUnknown,
we want to sink the SCEVPtrToIntExpr into an operand,
so that the operation is performed on integers,
and eventually we end up with just an `SCEVPtrToIntExpr(SCEVUnknown)`.

Reviewed By: mkazantsev

Differential Revision: https://reviews.llvm.org/D89692


Compare: https://github.com/llvm/llvm-project/compare/fc0892c1f9a3...b4916918e521


More information about the All-commits mailing list