Skip to content

Commit 8ac5d2d

Browse files
authored
ConstRange: test edge-cases of makeAllowedICmpRegion (#127080)
Exhaustively test signed-unsigned min-max edge-cases of makeAllowedICmpRegion.
1 parent a1120c9 commit 8ac5d2d

File tree

1 file changed

+27
-3
lines changed

1 file changed

+27
-3
lines changed

llvm/unittests/IR/ConstantRangeTest.cpp

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1631,11 +1631,35 @@ TEST_F(ConstantRangeTest, Ashr) {
16311631
ConstantRange(APInt(16, 0xfffc), APInt(16, 0xfffe)));
16321632
}
16331633

1634-
TEST(ConstantRange, MakeAllowedICmpRegion) {
1635-
// PR8250
1636-
ConstantRange SMax = ConstantRange(APInt::getSignedMaxValue(32));
1634+
TEST(ConstantRange, MakeAllowedICmpRegionEdgeCases) {
1635+
ConstantRange SMax = ConstantRange(APInt::getSignedMaxValue(8));
16371636
EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SGT, SMax)
16381637
.isEmptySet());
1638+
EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SGE, SMax)
1639+
.isSingleElement());
1640+
EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SLE, SMax)
1641+
.isFullSet());
1642+
ConstantRange SMin = ConstantRange(APInt::getSignedMinValue(8));
1643+
EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SLT, SMin)
1644+
.isEmptySet());
1645+
EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SLE, SMin)
1646+
.isSingleElement());
1647+
EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SGE, SMin)
1648+
.isFullSet());
1649+
ConstantRange UMax = ConstantRange(APInt::getMaxValue(8));
1650+
EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_UGT, UMax)
1651+
.isEmptySet());
1652+
EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_UGE, UMax)
1653+
.isSingleElement());
1654+
EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_ULE, UMax)
1655+
.isFullSet());
1656+
ConstantRange UMin = ConstantRange(APInt::getMinValue(8));
1657+
EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_ULT, UMin)
1658+
.isEmptySet());
1659+
EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_ULE, UMin)
1660+
.isSingleElement());
1661+
EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_UGE, UMin)
1662+
.isFullSet());
16391663
}
16401664

16411665
TEST(ConstantRange, MakeSatisfyingICmpRegion) {

0 commit comments

Comments
 (0)