[llvm] ConstRange: exhaustively test makeExactICmpRegion (PR #127058)

via llvm-commits llvm-commits at lists.llvm.org
Thu Feb 13 05:09:58 PST 2025


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-llvm-ir

Author: Ramkumar Ramachandra (artagnon)

<details>
<summary>Changes</summary>

Exhaustively test makeExactICmpRegion by comparing makeAllowedICmpRegion against makeSatisfyingICmpRegion for all APInts.

---
Full diff: https://github.com/llvm/llvm-project/pull/127058.diff


1 Files Affected:

- (modified) llvm/unittests/IR/ConstantRangeTest.cpp (+11) 


``````````diff
diff --git a/llvm/unittests/IR/ConstantRangeTest.cpp b/llvm/unittests/IR/ConstantRangeTest.cpp
index c390ffea1c352..a85e111146c01 100644
--- a/llvm/unittests/IR/ConstantRangeTest.cpp
+++ b/llvm/unittests/IR/ConstantRangeTest.cpp
@@ -1638,6 +1638,17 @@ TEST(ConstantRange, MakeAllowedICmpRegion) {
                   .isEmptySet());
 }
 
+TEST(ConstantRange, MakeExactICmpRegion) {
+  for (unsigned Bits : {1, 4}) {
+    EnumerateAPInts(Bits, [](const APInt &N) {
+      for (auto Pred : ICmpInst::predicates()) {
+        EXPECT_EQ(ConstantRange::makeAllowedICmpRegion(Pred, N),
+                  ConstantRange::makeSatisfyingICmpRegion(Pred, N));
+      };
+    });
+  }
+}
+
 TEST(ConstantRange, MakeSatisfyingICmpRegion) {
   ConstantRange LowHalf(APInt(8, 0), APInt(8, 128));
   ConstantRange HighHalf(APInt(8, 128), APInt(8, 0));

``````````

</details>


https://github.com/llvm/llvm-project/pull/127058


More information about the llvm-commits mailing list