[llvm] 8ac5d2d - ConstRange: test edge-cases of makeAllowedICmpRegion (#127080)
via llvm-commits
llvm-commits at lists.llvm.org
Sun Feb 16 04:40:06 PST 2025
Author: Ramkumar Ramachandra
Date: 2025-02-16T12:40:03Z
New Revision: 8ac5d2d1805ecb70b683531b602ac3d288351e97
URL: https://github.com/llvm/llvm-project/commit/8ac5d2d1805ecb70b683531b602ac3d288351e97
DIFF: https://github.com/llvm/llvm-project/commit/8ac5d2d1805ecb70b683531b602ac3d288351e97.diff
LOG: ConstRange: test edge-cases of makeAllowedICmpRegion (#127080)
Exhaustively test signed-unsigned min-max edge-cases of
makeAllowedICmpRegion.
Added:
Modified:
llvm/unittests/IR/ConstantRangeTest.cpp
Removed:
################################################################################
diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp b/llvm/unittests/IR/ConstantRangeTest.cpp
index daa07bf7d840d..1bafb52d357fa 100644
--- a/llvm/unittests/IR/ConstantRangeTest.cpp
+++ b/llvm/unittests/IR/ConstantRangeTest.cpp
@@ -1631,11 +1631,35 @@ TEST_F(ConstantRangeTest, Ashr) {
ConstantRange(APInt(16, 0xfffc), APInt(16, 0xfffe)));
}
-TEST(ConstantRange, MakeAllowedICmpRegion) {
- // PR8250
- ConstantRange SMax = ConstantRange(APInt::getSignedMaxValue(32));
+TEST(ConstantRange, MakeAllowedICmpRegionEdgeCases) {
+ ConstantRange SMax = ConstantRange(APInt::getSignedMaxValue(8));
EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SGT, SMax)
.isEmptySet());
+ EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SGE, SMax)
+ .isSingleElement());
+ EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SLE, SMax)
+ .isFullSet());
+ ConstantRange SMin = ConstantRange(APInt::getSignedMinValue(8));
+ EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SLT, SMin)
+ .isEmptySet());
+ EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SLE, SMin)
+ .isSingleElement());
+ EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_SGE, SMin)
+ .isFullSet());
+ ConstantRange UMax = ConstantRange(APInt::getMaxValue(8));
+ EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_UGT, UMax)
+ .isEmptySet());
+ EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_UGE, UMax)
+ .isSingleElement());
+ EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_ULE, UMax)
+ .isFullSet());
+ ConstantRange UMin = ConstantRange(APInt::getMinValue(8));
+ EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_ULT, UMin)
+ .isEmptySet());
+ EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_ULE, UMin)
+ .isSingleElement());
+ EXPECT_TRUE(ConstantRange::makeAllowedICmpRegion(ICmpInst::ICMP_UGE, UMin)
+ .isFullSet());
}
TEST(ConstantRange, MakeSatisfyingICmpRegion) {
More information about the llvm-commits
mailing list