[llvm] r305607 - [ConstantRange] Implement getSignedMin/Max in a less complicated and faster way
Craig Topper via llvm-commits
llvm-commits at lists.llvm.org
Fri Jun 16 16:26:23 PDT 2017
Author: ctopper
Date: Fri Jun 16 18:26:23 2017
New Revision: 305607
URL: http://llvm.org/viewvc/llvm-project?rev=305607&view=rev
Log:
[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
Modified:
llvm/trunk/lib/IR/ConstantRange.cpp
Modified: llvm/trunk/lib/IR/ConstantRange.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/IR/ConstantRange.cpp?rev=305607&r1=305606&r2=305607&view=diff
==============================================================================
--- llvm/trunk/lib/IR/ConstantRange.cpp (original)
+++ llvm/trunk/lib/IR/ConstantRange.cpp Fri Jun 16 18:26:23 2017
@@ -284,27 +284,14 @@ APInt ConstantRange::getUnsignedMin() co
}
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();
}
More information about the llvm-commits
mailing list