Index: lib/IR/ConstantRange.cpp =================================================================== --- lib/IR/ConstantRange.cpp +++ lib/IR/ConstantRange.cpp @@ -979,7 +979,7 @@ APInt Other_umax = Other.getUnsignedMax(); // there's overflow! - if (Other_umax.uge(max.countLeadingZeros())) + if (Other_umax.ugt(max.countLeadingZeros())) return ConstantRange(getBitWidth(), /*isFullSet=*/true); // FIXME: implement the other tricky cases Index: unittests/IR/ConstantRangeTest.cpp =================================================================== --- unittests/IR/ConstantRangeTest.cpp +++ unittests/IR/ConstantRangeTest.cpp @@ -21,6 +21,7 @@ static ConstantRange Empty; static ConstantRange One; static ConstantRange Some; + static ConstantRange Some2; static ConstantRange Wrap; }; @@ -28,6 +29,7 @@ ConstantRange ConstantRangeTest::Empty(16, false); ConstantRange ConstantRangeTest::One(APInt(16, 0xa)); ConstantRange ConstantRangeTest::Some(APInt(16, 0xa), APInt(16, 0xaaa)); +ConstantRange ConstantRangeTest::Some2(APInt(16, 0xfff), APInt(16, 0x8000)); ConstantRange ConstantRangeTest::Wrap(APInt(16, 0xaaa), APInt(16, 0xa)); TEST_F(ConstantRangeTest, Basics) { @@ -582,6 +584,8 @@ EXPECT_EQ(Some.shl(Some), Full); // TODO: [0xa << 0xa, 0xfc01) EXPECT_EQ(Some.shl(Wrap), Full); // TODO: [0xa, 0x7ff << 0x5 + 1) EXPECT_EQ(Wrap.shl(Wrap), Full); + EXPECT_EQ(Some2.shl(ConstantRange(APInt(16, 0x1))), + ConstantRange(APInt(16, 0xfff << 0x1), APInt(16, 0x7fff << 0x1) + 1)); } TEST_F(ConstantRangeTest, Lshr) {