llvm.org GIT mirror
[ConstantRange] Fix the early out in ConstantRange::multiply for positive numbers to really do what the comment says r271020 added an early out to skip the signed multiply portion of ConstantRange::multiply. The comment says we don't need to do signed multiply if the range is only positive numbers, but the implemented check only ensures that the start of the range is positive. It doesn't look at the end of the range. This patch checks the end of the range instead. Because Upper is one more than the end we have to see if its positive or if its one past the last positive number. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@302717 91177308-0d34-0410-b5e6-96231b3b80d8 Craig Topper 3 years ago
2 changed file(s) with 3 addition(s) and 2 deletion(s).
 756 756 // from one positive number to another which is as good as we can generate. 757 757 // In this case, skip the extra work of generating signed ranges which aren't 758 758 // going to be better than this range. 759 if (!UR.isWrappedSet() && UR.getLower().isNonNegative())⏎ 759 if (!UR.isWrappedSet() &&⏎ 760 (UR.getUpper().isNonNegative() || UR.getUpper().isMinSignedValue())) 760 761 return UR; 761 762 762 763 // Now the signed range. Because we could be dealing with negative numbers
 446 446 // TODO: This should be return [-2, 0] 447 447 EXPECT_EQ(ConstantRange(APInt(8, -2)).multiply( 448 448 ConstantRange(APInt(8, 0), APInt(8, 2))), 449 ConstantRange(APInt(8, 0), APInt(8, 255)));⏎ 449 ConstantRange(APInt(8, -2), APInt(8, 1)));⏎ 450 450 } 451 451 452 452 TEST_F(ConstantRangeTest, UMax) {