Index: lib/IR/ConstantRange.cpp =================================================================== --- lib/IR/ConstantRange.cpp +++ lib/IR/ConstantRange.cpp @@ -757,7 +757,8 @@ // from one positive number to another which is as good as we can generate. // In this case, skip the extra work of generating signed ranges which aren't // going to be better than this range. - if (!UR.isWrappedSet() && UR.getLower().isNonNegative()) + if (!UR.isWrappedSet() && + (UR.getUpper().isNonNegative() || UR.getUpper().isMinSignedValue())) return UR; // Now the signed range. Because we could be dealing with negative numbers Index: unittests/IR/ConstantRangeTest.cpp =================================================================== --- unittests/IR/ConstantRangeTest.cpp +++ unittests/IR/ConstantRangeTest.cpp @@ -447,7 +447,7 @@ // TODO: This should be return [-2, 0] EXPECT_EQ(ConstantRange(APInt(8, -2)).multiply( ConstantRange(APInt(8, 0), APInt(8, 2))), - ConstantRange(APInt(8, 0), APInt(8, 255))); + ConstantRange(APInt(8, -2), APInt(8, 1))); } TEST_F(ConstantRangeTest, UMax) {