From 646ca92bfc20002a5c6d9b2b42e6940fd86ff7c9 Mon Sep 17 00:00:00 2001 From: Nick Lewycky Date: Sat, 11 Jul 2009 19:22:21 +0000 Subject: Fix handling of max and full set. A full set is a constant range that represents any number. If you take the umax of that and [5, 10) you end up with [5, INT_MAX] because the values less than 5 would be umax's against a value which is at least 5. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@75372 91177308-0d34-0410-b5e6-96231b3b80d8 --- unittests/Support/ConstantRangeTest.cpp | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'unittests/Support/ConstantRangeTest.cpp') diff --git a/unittests/Support/ConstantRangeTest.cpp b/unittests/Support/ConstantRangeTest.cpp index ccac180147..83bf535028 100644 --- a/unittests/Support/ConstantRangeTest.cpp +++ b/unittests/Support/ConstantRangeTest.cpp @@ -184,7 +184,6 @@ TEST_F(ConstantRangeTest, SExt) { APInt(Some.getUpper()).sext(20))); EXPECT_EQ(SWrap, ConstantRange(APInt(Wrap.getLower()).sext(20), APInt(Wrap.getUpper()).sext(20))); - } TEST_F(ConstantRangeTest, IntersectWith) { @@ -285,9 +284,9 @@ TEST_F(ConstantRangeTest, Multiply) { TEST_F(ConstantRangeTest, UMax) { EXPECT_TRUE(Full.umax(Full).isFullSet()); EXPECT_TRUE(Full.umax(Empty).isEmptySet()); - EXPECT_TRUE(Full.umax(Some).isFullSet()); + EXPECT_EQ(Full.umax(Some), ConstantRange(APInt(16, 0xa), APInt(16, 0))); EXPECT_TRUE(Full.umax(Wrap).isFullSet()); - EXPECT_TRUE(Full.umax(One).isFullSet()); + EXPECT_EQ(Full.umax(Some), ConstantRange(APInt(16, 0xa), APInt(16, 0))); EXPECT_EQ(Empty.umax(Empty), Empty); EXPECT_EQ(Empty.umax(Some), Empty); EXPECT_EQ(Empty.umax(Wrap), Empty); @@ -304,19 +303,21 @@ TEST_F(ConstantRangeTest, UMax) { TEST_F(ConstantRangeTest, SMax) { EXPECT_TRUE(Full.smax(Full).isFullSet()); EXPECT_TRUE(Full.smax(Empty).isEmptySet()); - EXPECT_TRUE(Full.smax(Some).isFullSet()); + EXPECT_EQ(Full.smax(Some), ConstantRange(APInt(16, 0xa), + APInt::getSignedMinValue(16))); EXPECT_TRUE(Full.smax(Wrap).isFullSet()); - EXPECT_TRUE(Full.smax(One).isFullSet()); + EXPECT_EQ(Full.smax(One), ConstantRange(APInt(16, 0xa), + APInt::getSignedMinValue(16))); EXPECT_EQ(Empty.smax(Empty), Empty); EXPECT_EQ(Empty.smax(Some), Empty); EXPECT_EQ(Empty.smax(Wrap), Empty); EXPECT_EQ(Empty.smax(One), Empty); EXPECT_EQ(Some.smax(Some), Some); EXPECT_EQ(Some.smax(Wrap), ConstantRange(APInt(16, 0xa), - APInt(16, INT16_MIN))); + APInt(16, INT16_MIN))); EXPECT_EQ(Some.smax(One), Some); EXPECT_EQ(Wrap.smax(One), ConstantRange(APInt(16, 0xa), - APInt(16, INT16_MIN))); + APInt(16, INT16_MIN))); EXPECT_EQ(One.smax(One), One); } -- cgit v1.2.3-70-g09d2