[ConstantRange] Add srem() support
authorNikita Popov <nikita.ppv@gmail.com>
Mon, 6 May 2019 16:59:37 +0000 (16:59 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Mon, 6 May 2019 16:59:37 +0000 (16:59 +0000)
commitd5a403fb80c69e2bc56e4dda0afb5ef0b9e31e4a
treebf8fd3777a6d062334510cd2e21acbdfc66aebe3
parentcfe786a19567424b04206bea5b5f1817fe9041b4
[ConstantRange] Add srem() support

Add support for srem() to ConstantRange so we can use it in LVI. For
srem the sign of the result matches the sign of the LHS. For the RHS
only the absolute value is important. Apart from that the logic is
like urem.

Just like for urem this is only an approximate implementation. The tests
check a few specific cases and run an exhaustive test for conservative
correctness (but not exactness).

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

llvm-svn: 360055
llvm/include/llvm/IR/ConstantRange.h
llvm/lib/IR/ConstantRange.cpp
llvm/unittests/IR/ConstantRangeTest.cpp