// separately by combining division results with the appropriate signs.
APInt Zero = APInt::getZero(getBitWidth());
APInt SignedMin = APInt::getSignedMinValue(getBitWidth());
- ConstantRange PosFilter(APInt(getBitWidth(), 1), SignedMin);
+ // There are no positive 1-bit values. The 1 would get interpreted as -1.
+ ConstantRange PosFilter =
+ getBitWidth() == 1 ? getEmpty()
+ : ConstantRange(APInt(getBitWidth(), 1), SignedMin);
ConstantRange NegFilter(SignedMin, Zero);
ConstantRange PosL = intersectWith(PosFilter);
ConstantRange NegL = intersectWith(NegFilter);
}
TEST_F(ConstantRangeTest, SDiv) {
+ ConstantRange OneBit = ConstantRange::getFull(1);
+ EXPECT_EQ(OneBit.sdiv(OneBit), ConstantRange(APInt(1, 0)));
+
unsigned Bits = 4;
EnumerateTwoConstantRanges(Bits, [&](const ConstantRange &CR1,
const ConstantRange &CR2) {