summaryrefslogtreecommitdiffstats
path: root/llvm/lib/IR/ConstantRange.cpp
diff options
context:
space:
mode:
authorCraig Topper <craig.topper@intel.com>2017-06-16 23:26:23 +0000
committerCraig Topper <craig.topper@intel.com>2017-06-16 23:26:23 +0000
commit61e684adcca96b26913f1b118cdfa63f42b0ab1a (patch)
tree7c5c488f14cd5921b05d03cb425886c2c2685941 /llvm/lib/IR/ConstantRange.cpp
parent288b3c9e69964496f4560f3efb7dac62949b1236 (diff)
downloadbcm5719-llvm-61e684adcca96b26913f1b118cdfa63f42b0ab1a.tar.gz
bcm5719-llvm-61e684adcca96b26913f1b118cdfa63f42b0ab1a.zip
[ConstantRange] Implement getSignedMin/Max in a less complicated and faster way
Summary: As far as I can tell we should be able to implement these almost the same way we do unsigned, but using signed comparisons and checks for min signed value instead of min unsigned value. Reviewers: pete, davide, sanjoy Reviewed By: davide Subscribers: llvm-commits Differential Revision: https://reviews.llvm.org/D33815 llvm-svn: 305607
Diffstat (limited to 'llvm/lib/IR/ConstantRange.cpp')
-rw-r--r--llvm/lib/IR/ConstantRange.cpp17
1 files changed, 2 insertions, 15 deletions
diff --git a/llvm/lib/IR/ConstantRange.cpp b/llvm/lib/IR/ConstantRange.cpp
index 21d1996ef85..5f44af20635 100644
--- a/llvm/lib/IR/ConstantRange.cpp
+++ b/llvm/lib/IR/ConstantRange.cpp
@@ -284,27 +284,14 @@ APInt ConstantRange::getUnsignedMin() const {
}
APInt ConstantRange::getSignedMax() const {
- if (!isWrappedSet()) {
- APInt UpperMinusOne = getUpper() - 1;
- if (getLower().sle(UpperMinusOne))
- return UpperMinusOne;
- return APInt::getSignedMaxValue(getBitWidth());
- }
- if (getLower().isNegative() == getUpper().isNegative())
+ if (isFullSet() || Lower.sgt(Upper))
return APInt::getSignedMaxValue(getBitWidth());
return getUpper() - 1;
}
APInt ConstantRange::getSignedMin() const {
- if (!isWrappedSet()) {
- if (getLower().sle(getUpper() - 1))
- return getLower();
+ if (isFullSet() || (Lower.sgt(Upper) && !getUpper().isMinSignedValue()))
return APInt::getSignedMinValue(getBitWidth());
- }
- if ((getUpper() - 1).slt(getLower())) {
- if (!getUpper().isMinSignedValue())
- return APInt::getSignedMinValue(getBitWidth());
- }
return getLower();
}
OpenPOWER on IntegriCloud