llvm.org GIT mirror llvm / b97a02c
[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). Raw diff Collapse all Expand all
756756 // from one positive number to another which is as good as we can generate.
757757 // In this case, skip the extra work of generating signed ranges which aren't
758758 // 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()))
760761 return UR;
761762
762763 // Now the signed range. Because we could be dealing with negative numbers
446446 // TODO: This should be return [-2, 0]
447447 EXPECT_EQ(ConstantRange(APInt(8, -2)).multiply(
448448 ConstantRange(APInt(8, 0), APInt(8, 2))),
449 ConstantRange(APInt(8, 0), APInt(8, 255)));
449 ConstantRange(APInt(8, -2), APInt(8, 1)));
450450 }
451451
452452 TEST_F(ConstantRangeTest, UMax) {