OSDN Git Service

[ConstantRange] Add abs() support
authorNikita Popov <nikita.ppv@gmail.com>
Fri, 26 Apr 2019 16:50:31 +0000 (16:50 +0000)
committerNikita Popov <nikita.ppv@gmail.com>
Fri, 26 Apr 2019 16:50:31 +0000 (16:50 +0000)
commit0393ba9ec6616854e5025de421163a7588068f09
tree3da1ea675cca4ff3d2899a1007b3229db1d77bef
parent4027ba94cd5931ba4597001a59bd6487497e30c9
[ConstantRange] Add abs() support

Add support for abs() to ConstantRange. This will allow to handle
SPF_ABS select flavor in LVI and will also come in handy as a
primitive for the srem implementation.

The implementation is slightly tricky, because a) abs of signed min
is signed min and b) sign-wrapped ranges may have an abs() that is
smaller than a full range, so we need to explicitly handle them.

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

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