]> granicus.if.org Git - llvm/commit
[ConstantRange] makeGuaranteedNoWrapRegion(): `shl` support
authorRoman Lebedev <lebedev.ri@gmail.com>
Sun, 20 Oct 2019 19:36:55 +0000 (19:36 +0000)
committerRoman Lebedev <lebedev.ri@gmail.com>
Sun, 20 Oct 2019 19:36:55 +0000 (19:36 +0000)
commit7bd6e166d9c76d62f76e801f9b55a84de03eb733
treefa8498ec24832b84d92bc1e1cf8561ad41496727
parent467514942a5076757f238930fae0a7a6e9004af2
[ConstantRange] makeGuaranteedNoWrapRegion(): `shl` support

Summary:
If all the shifts amount are already poison-producing,
then we can add more poison-producing flags ontop:
https://rise4fun.com/Alive/Ocwi

Otherwise, we should only consider the possible range of shift amts that don't result in poison.

For unsigned range not not overflow, we must not shift out any set bits,
and the actual limit for `x` can be computed by backtransforming
the maximal value we could ever get out of the `shl` - `-1` through
`lshr`. If the `x` is any larger than that then it will overflow.

Likewise for signed range, but just in signed domain..

This is based on the general idea outlined by @nikic in https://reviews.llvm.org/D68672#1714990

Reviewers: nikic, sanjoy

Reviewed By: nikic

Subscribers: hiraditya, llvm-commits, nikic

Tags: #llvm

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

git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@375370 91177308-0d34-0410-b5e6-96231b3b80d8
lib/IR/ConstantRange.cpp
unittests/IR/ConstantRangeTest.cpp