diff options
| -rw-r--r-- | llvm/lib/Support/ConstantRange.cpp | 10 | ||||
| -rw-r--r-- | llvm/unittests/Support/ConstantRangeTest.cpp | 4 | 
2 files changed, 7 insertions, 7 deletions
diff --git a/llvm/lib/Support/ConstantRange.cpp b/llvm/lib/Support/ConstantRange.cpp index ca25491f623..4cb54bde1bd 100644 --- a/llvm/lib/Support/ConstantRange.cpp +++ b/llvm/lib/Support/ConstantRange.cpp @@ -159,14 +159,10 @@ APInt ConstantRange::getSignedMax() const {      else        return SignedMax;    } else { -    if ((getUpper() - 1).slt(getLower())) { -      if (getLower() != SignedMax) -        return SignedMax; -      else -        return getUpper() - 1; -    } else { +    if (getLower().isNegative() == getUpper().isNegative()) +      return SignedMax; +    else        return getUpper() - 1; -    }    }  } diff --git a/llvm/unittests/Support/ConstantRangeTest.cpp b/llvm/unittests/Support/ConstantRangeTest.cpp index f929425e547..3ebb92967fd 100644 --- a/llvm/unittests/Support/ConstantRangeTest.cpp +++ b/llvm/unittests/Support/ConstantRangeTest.cpp @@ -137,6 +137,10 @@ TEST_F(ConstantRangeTest, GetMinsAndMaxes) {    EXPECT_EQ(One.getSignedMin(), APInt(16, 0xa));    EXPECT_EQ(Some.getSignedMin(), APInt(16, 0xa));    EXPECT_EQ(Wrap.getSignedMin(), APInt(16, INT16_MIN)); + +  // Found by Klee +  EXPECT_EQ(ConstantRange(APInt(4, 7), APInt(4, 0)).getSignedMax(), +            APInt(4, 7));  }  TEST_F(ConstantRangeTest, Trunc) {  | 

