[all-commits] [llvm/llvm-project] bd6d41: [NFC][SCEV] Add some more ptrtoint/PR46786 -relate...
Roman Lebedev via All-commits
all-commits at lists.llvm.org
Sat Oct 17 11:23:21 PDT 2020
Branch: refs/heads/master
Home: https://github.com/llvm/llvm-project
Commit: bd6d41f52e5655af3db28095c7574bae6b0cd788
https://github.com/llvm/llvm-project/commit/bd6d41f52e5655af3db28095c7574bae6b0cd788
Author: Roman Lebedev <lebedev.ri at gmail.com>
Date: 2020-10-17 (Sat, 17 Oct 2020)
Changed paths:
A llvm/test/Analysis/ScalarEvolution/ashr.ll
M llvm/test/Analysis/ScalarEvolution/ptrtoint.ll
Log Message:
-----------
[NFC][SCEV] Add some more ptrtoint/PR46786 -related tests
Commit: be1678bdb9d46ad7a1076dd10a773c4b457c072d
https://github.com/llvm/llvm-project/commit/be1678bdb9d46ad7a1076dd10a773c4b457c072d
Author: Roman Lebedev <lebedev.ri at gmail.com>
Date: 2020-10-17 (Sat, 17 Oct 2020)
Changed paths:
M llvm/include/llvm/Analysis/ScalarEvolution.h
M llvm/lib/Analysis/ScalarEvolution.cpp
Log Message:
-----------
[NFC][SCEV] Add 'getMinusOne()' method
Commit: 130cc662b5d313db69b136d880ebe44e58b25418
https://github.com/llvm/llvm-project/commit/130cc662b5d313db69b136d880ebe44e58b25418
Author: Roman Lebedev <lebedev.ri at gmail.com>
Date: 2020-10-17 (Sat, 17 Oct 2020)
Changed paths:
M llvm/include/llvm/Analysis/ScalarEvolution.h
M llvm/lib/Analysis/ScalarEvolution.cpp
Log Message:
-----------
[NFC][SCEV] Refactor getAbsExpr() out of createSCEV()
Commit: ec54867df5e7f20e12146e628af34f0384308bcb
https://github.com/llvm/llvm-project/commit/ec54867df5e7f20e12146e628af34f0384308bcb
Author: Roman Lebedev <lebedev.ri at gmail.com>
Date: 2020-10-17 (Sat, 17 Oct 2020)
Changed paths:
M llvm/include/llvm/Analysis/ScalarEvolution.h
M llvm/lib/Analysis/ScalarEvolution.cpp
M llvm/test/Analysis/ScalarEvolution/ashr.ll
M llvm/test/Analysis/ScalarEvolution/ptrtoint.ll
Log Message:
-----------
[SCEV] Model `ashr exact x, C` as `(abs(x) EXACT/u (1<<C)) * signum(x)`
It's not pretty, but probably better than modelling it
as an opaque SCEVUnknown, i guess.
It is relevant e.g. for the loop that was brought up in
https://bugs.llvm.org/show_bug.cgi?id=46786#c26
as an example of what we'd be able to better analyze
once SCEV handles `ptrtoint` (D89456).
But as it is evident, even if we deal with `ptrtoint` there,
we also fail to model such an `ashr`.
Also, modeling of mul-of-exact-shr/div could use improvement.
As per alive2:
https://alive2.llvm.org/ce/z/tnfZKd
```
define i8 @src(i8 %0) {
%2 = ashr exact i8 %0, 4
ret i8 %2
}
declare i8 @llvm.abs(i8, i1)
declare i8 @llvm.smin(i8, i8)
declare i8 @llvm.smax(i8, i8)
define i8 @tgt(i8 %x) {
%abs_x = call i8 @llvm.abs(i8 %x, i1 false)
%div = udiv exact i8 %abs_x, 16
%t0 = call i8 @llvm.smax(i8 %x, i8 -1)
%t1 = call i8 @llvm.smin(i8 %t0, i8 1)
%r = mul nsw i8 %div, %t1
ret i8 %r
}
```
Transformation seems to be correct!
Compare: https://github.com/llvm/llvm-project/compare/b9e789447f14...ec54867df5e7
More information about the All-commits
mailing list