1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-26 04:32:44 +01:00

Fix the implementation of ConstantRange::sub(ConstantRange). Patch by Xi Wang!

llvm-svn: 133648
This commit is contained in:
Nick Lewycky 2011-06-22 21:13:46 +00:00
parent 5e6ecb23a4
commit 5e5818d0f8
2 changed files with 4 additions and 2 deletions

View File

@ -529,8 +529,8 @@ ConstantRange::sub(const ConstantRange &Other) const {
return ConstantRange(getBitWidth(), /*isFullSet=*/true);
APInt Spread_X = getSetSize(), Spread_Y = Other.getSetSize();
APInt NewLower = getLower() - Other.getLower();
APInt NewUpper = getUpper() - Other.getUpper() + 1;
APInt NewLower = getLower() - Other.getUpper() + 1;
APInt NewUpper = getUpper() - Other.getLower();
if (NewLower == NewUpper)
return ConstantRange(getBitWidth(), /*isFullSet=*/true);

View File

@ -299,6 +299,8 @@ TEST_F(ConstantRangeTest, Sub) {
EXPECT_EQ(Empty.sub(APInt(16, 4)), Empty);
EXPECT_EQ(Some.sub(APInt(16, 4)),
ConstantRange(APInt(16, 0x6), APInt(16, 0xaa6)));
EXPECT_EQ(Some.sub(Some),
ConstantRange(APInt(16, 0xf561), APInt(16, 0xaa0)));
EXPECT_EQ(Wrap.sub(APInt(16, 4)),
ConstantRange(APInt(16, 0xaa6), APInt(16, 0x6)));
EXPECT_EQ(One.sub(APInt(16, 4)),