aboutsummaryrefslogtreecommitdiff
path: root/clang/lib/CodeGen/CodeGenFunction.cpp
diff options
context:
space:
mode:
authorRoman Lebedev <lebedev.ri@gmail.com>2020-10-17 21:04:26 +0300
committerRoman Lebedev <lebedev.ri@gmail.com>2020-10-17 21:22:24 +0300
commitec54867df5e7f20e12146e628af34f0384308bcb (patch)
treebf8400381f7a18781b92e279137f46273e9c1db0 /clang/lib/CodeGen/CodeGenFunction.cpp
parent130cc662b5d313db69b136d880ebe44e58b25418 (diff)
downloadllvm-ec54867df5e7f20e12146e628af34f0384308bcb.zip
llvm-ec54867df5e7f20e12146e628af34f0384308bcb.tar.gz
llvm-ec54867df5e7f20e12146e628af34f0384308bcb.tar.bz2
[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!
Diffstat (limited to 'clang/lib/CodeGen/CodeGenFunction.cpp')
0 files changed, 0 insertions, 0 deletions