[Mlir-commits] [mlir] [mlir][arith] Add ValueBoundsOpInterface external models for the arith operations DivUI and DivSI (PR #206514)

Hagai Lev Hacohen llvmlistbot at llvm.org
Tue Jun 30 02:24:23 PDT 2026


https://github.com/HagaiLevHacohen updated https://github.com/llvm/llvm-project/pull/206514

>From 494e0b985b3a5aca135ff3b46a7f9e924da2ba12 Mon Sep 17 00:00:00 2001
From: Hagai Lev Hacohen <hagai4000 at gmail.com>
Date: Mon, 29 Jun 2026 18:46:28 +0300
Subject: [PATCH 1/9] implementing valuebounds interface for divui and divsi

resolved merge conflict, and removed duplicate constantOp
---
 mlir/lib/Dialect/Arith/IR/ArithDialect.cpp    |  4 +-
 .../Arith/IR/ValueBoundsOpInterfaceImpl.cpp   | 58 ++++++++++++++++++
 .../Arith/value-bounds-op-interface-impl.mlir | 59 +++++++++++++++++++
 3 files changed, 119 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp b/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
index 2a342eaba4e61..e2059ff07e76f 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
@@ -56,9 +56,9 @@ void arith::ArithDialect::initialize() {
   declarePromisedInterfaces<bufferization::BufferizableOpInterface, ConstantOp,
                             IndexCastOp, SelectOp>();
   declarePromisedInterfaces<ValueBoundsOpInterface, ConstantOp, ExtSIOp, AddIOp,
-                            ConstantOp, SubIOp, MulIOp, SelectOp, FloorDivSIOp,
+                            SubIOp, MulIOp, SelectOp, FloorDivSIOp,
                             CeilDivSIOp, MinSIOp, MaxSIOp, MinUIOp, MaxUIOp,
-                            RemSIOp, RemUIOp>();
+                            RemSIOp, RemUIOp, DivUIOp, DivSIOp>();
 }
 
 /// Materialize an integer or floating point constant.
diff --git a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
index c9fd446a26a83..5c91ada341e8f 100644
--- a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
@@ -62,6 +62,62 @@ struct AddIOpInterface
   }
 };
 
+struct DivUIOpInterface
+    : public ValueBoundsOpInterface::ExternalModel<DivUIOpInterface,
+                                                   arith::DivUIOp> {
+  void populateBoundsForIndexValue(Operation *op, Value value,
+                                   ValueBoundsConstraintSet &cstr) const {
+    auto divOp = cast<arith::DivUIOp>(op);
+    assert(value == divOp.getResult() && "invalid value");
+
+    bool lhsNonNegative =
+        ValueBoundsConstraintSet::isProvablyNonNegative(divOp.getLhs(), cstr);
+    bool rhsPositive =
+        ValueBoundsConstraintSet::isProvablyPositive(divOp.getRhs(), cstr);
+    if (!lhsNonNegative || !rhsPositive)
+      return;
+
+    AffineExpr lhs = cstr.getExpr(divOp.getLhs());
+    AffineExpr rhs = cstr.getExpr(divOp.getRhs());
+    cstr.bound(value) >= 0;
+    cstr.bound(value) == lhs.floorDiv(rhs);
+  }
+};
+
+struct DivSIOpInterface
+    : public ValueBoundsOpInterface::ExternalModel<DivSIOpInterface,
+                                                   arith::DivSIOp> {
+  void populateBoundsForIndexValue(Operation *op, Value value,
+                                   ValueBoundsConstraintSet &cstr) const {
+    auto divOp = cast<arith::DivSIOp>(op);
+    assert(value == divOp.getResult() && "invalid value");
+
+    Value lhsValue = divOp.getLhs();
+    Value rhsValue = divOp.getRhs();
+
+    bool lhsNonNegative =
+        ValueBoundsConstraintSet::isProvablyNonNegative(lhsValue, cstr);
+    bool lhsNonPositive =
+        ValueBoundsConstraintSet::isProvablyNonPositive(lhsValue, cstr);
+    bool rhsPositive =
+        ValueBoundsConstraintSet::isProvablyPositive(rhsValue, cstr);
+    bool rhsNegative =
+        ValueBoundsConstraintSet::isProvablyNegative(rhsValue, cstr);
+    if ((!lhsNonNegative && !lhsNonPositive) || (!rhsPositive && !rhsNegative))
+      return;
+
+    AffineExpr lhs = cstr.getExpr(lhsValue);
+    AffineExpr rhs = cstr.getExpr(rhsValue);
+    if ((lhsNonNegative && rhsPositive) || (lhsNonPositive && rhsNegative)) {
+      cstr.bound(value) == lhs.floorDiv(rhs);
+      cstr.bound(value) >= 0;
+    } else if ((lhsNonPositive && rhsPositive) || (lhsNonNegative && rhsNegative)) {
+      cstr.bound(value) == lhs.ceilDiv(rhs);
+      cstr.bound(value) <= 0;
+    }
+  }
+};
+
 struct SubIOpInterface
     : public ValueBoundsOpInterface::ExternalModel<SubIOpInterface, SubIOp> {
   void populateBoundsForIndexValue(Operation *op, Value value,
@@ -338,6 +394,8 @@ void mlir::arith::registerValueBoundsOpInterfaceExternalModels(
     arith::ConstantOp::attachInterface<arith::ConstantOpInterface>(*ctx);
     arith::ExtSIOp::attachInterface<arith::ExtSIOpInterface>(*ctx);
     arith::AddIOp::attachInterface<arith::AddIOpInterface>(*ctx);
+    arith::DivUIOp::attachInterface<arith::DivUIOpInterface>(*ctx);
+    arith::DivSIOp::attachInterface<arith::DivSIOpInterface>(*ctx);
     arith::SubIOp::attachInterface<arith::SubIOpInterface>(*ctx);
     arith::MulIOp::attachInterface<arith::MulIOpInterface>(*ctx);
     arith::FloorDivSIOp::attachInterface<arith::FloorDivSIOpInterface>(*ctx);
diff --git a/mlir/test/Dialect/Arith/value-bounds-op-interface-impl.mlir b/mlir/test/Dialect/Arith/value-bounds-op-interface-impl.mlir
index 5871a67d618c2..a0a4eb6120407 100644
--- a/mlir/test/Dialect/Arith/value-bounds-op-interface-impl.mlir
+++ b/mlir/test/Dialect/Arith/value-bounds-op-interface-impl.mlir
@@ -136,6 +136,65 @@ func.func @arith_ceildivsi_non_pure(%a: index, %b: index) -> index {
 
 // -----
 
+// CHECK-LABEL: func @arith_divui_constant()
+//       CHECK:   %[[c1:.*]] = arith.constant 1 : index
+//       CHECK:   return %[[c1]]
+func.func @arith_divui_constant() -> index {
+  %c7 = arith.constant 7 : index
+  %c5 = arith.constant 5 : index
+  %0 = arith.divui %c7, %c5 : index
+  %1 = "test.reify_bound"(%0) : (index) -> (index)
+  return %1 : index
+}
+
+// -----
+
+
+// CHECK-LABEL: func @arith_divui_positive_lhs()
+//       CHECK:   %[[c1:.*]] = arith.constant 1 : index
+//       CHECK:   return %[[c1]]
+
+func.func @arith_divui_positive_lhs() -> index {
+  %c7 = arith.constant 7 : index
+  %c5 = arith.constant 5 : index
+  %c1 = arith.constant 1 : index
+  %lhs = arith.maxsi %c7, %c1 : index
+  %0 = arith.divui %lhs, %c5 : index
+  %1 = "test.reify_bound"(%0) {type = "LB", constant} : (index) -> (index)
+  return %1 : index
+}
+
+
+// -----
+
+// CHECK-LABEL: func @arith_divsi_negative_positive()
+//       CHECK:   %[[cm1:.*]] = arith.constant -1 : index
+//       CHECK:   return %[[cm1]]
+func.func @arith_divsi_negative_positive() -> index {
+  %cm7 = arith.constant -7 : index
+  %c5 = arith.constant 5 : index
+  %0 = arith.divsi %cm7, %c5 : index
+  %1 = "test.reify_bound"(%0) : (index) -> (index)
+  return %1 : index
+}
+
+// -----
+
+// CHECK-LABEL: func @arith_divsi_negative_lhs()
+//       CHECK:   %[[cm2:.*]] = arith.constant -2 : index
+//       CHECK:   return %[[cm2]]
+func.func @arith_divsi_negative_lhs() -> index {
+  %c2 = arith.constant 2 : index
+  %cm7 = arith.constant -7 : index
+  %cm5 = arith.constant -5 : index
+  %lhs = arith.minsi %cm5, %cm7 : index
+  %0 = arith.divsi %lhs, %c2 : index
+  %1 = "test.reify_bound"(%0) {type = "UB", constant}: (index) -> (index)
+  return %1 : index
+}
+
+// -----
+
 // CHECK-LABEL: func @arith_remsi_positive_positive()
 //       CHECK:   %[[c0:.*]] = arith.constant 0 : index
 //       CHECK:   %[[c5:.*]] = arith.constant 5 : index

>From 3c10b7e806574a09e3f47ddfd14b5d6a1c0d0f13 Mon Sep 17 00:00:00 2001
From: Hagai Lev Hacohen <hagai4000 at gmail.com>
Date: Mon, 29 Jun 2026 18:47:41 +0300
Subject: [PATCH 2/9] clang format

---
 mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
index 5c91ada341e8f..c7cd1b361f577 100644
--- a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
@@ -111,7 +111,8 @@ struct DivSIOpInterface
     if ((lhsNonNegative && rhsPositive) || (lhsNonPositive && rhsNegative)) {
       cstr.bound(value) == lhs.floorDiv(rhs);
       cstr.bound(value) >= 0;
-    } else if ((lhsNonPositive && rhsPositive) || (lhsNonNegative && rhsNegative)) {
+    } else if ((lhsNonPositive && rhsPositive) ||
+               (lhsNonNegative && rhsNegative)) {
       cstr.bound(value) == lhs.ceilDiv(rhs);
       cstr.bound(value) <= 0;
     }

>From 828fea139e4325a97c67c3ae6b3a074dfa09dc31 Mon Sep 17 00:00:00 2001
From: Hagai Lev Hacohen <hagai4000 at gmail.com>
Date: Mon, 29 Jun 2026 19:04:14 +0300
Subject: [PATCH 3/9] rearrangement to avoid conflict

rebase to avoid conflict
---
 mlir/lib/Dialect/Arith/IR/ArithDialect.cpp | 23 +++++++++++++++++-----
 1 file changed, 18 insertions(+), 5 deletions(-)

diff --git a/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp b/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
index e2059ff07e76f..e9347625329c9 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
@@ -55,11 +55,24 @@ void arith::ArithDialect::initialize() {
                            SelectOp>();
   declarePromisedInterfaces<bufferization::BufferizableOpInterface, ConstantOp,
                             IndexCastOp, SelectOp>();
-  declarePromisedInterfaces<ValueBoundsOpInterface, ConstantOp, ExtSIOp, AddIOp,
-                            SubIOp, MulIOp, SelectOp, FloorDivSIOp,
-                            CeilDivSIOp, MinSIOp, MaxSIOp, MinUIOp, MaxUIOp,
-                            RemSIOp, RemUIOp, DivUIOp, DivSIOp>();
-}
+  declarePromisedInterfaces<ValueBoundsOpInterface,
+                            ConstantOp,
+                            ExtSIOp,
+                            AddIOp,
+                            SubIOp,
+                            MulIOp,
+                            SelectOp,
+                            FloorDivSIOp,
+                            CeilDivSIOp,
+                            MinSIOp,
+                            MaxSIOp,
+                            MinUIOp,
+                            MaxUIOp,
+                            RemSIOp,
+                            RemUIOp,
+                            DivUIOp,
+                            DivSIOp>();
+  }
 
 /// Materialize an integer or floating point constant.
 Operation *arith::ArithDialect::materializeConstant(OpBuilder &builder,

>From d9b7a44e49a6a590f2aadb8350450124bf056867 Mon Sep 17 00:00:00 2001
From: Hagai Lev Hacohen <hagai4000 at gmail.com>
Date: Mon, 29 Jun 2026 19:04:49 +0300
Subject: [PATCH 4/9] clang format

resolve conflict
---
 mlir/lib/Dialect/Arith/IR/ArithDialect.cpp | 22 +++++-----------------
 1 file changed, 5 insertions(+), 17 deletions(-)

diff --git a/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp b/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
index e9347625329c9..7333d51f0a3df 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
@@ -55,23 +55,11 @@ void arith::ArithDialect::initialize() {
                            SelectOp>();
   declarePromisedInterfaces<bufferization::BufferizableOpInterface, ConstantOp,
                             IndexCastOp, SelectOp>();
-  declarePromisedInterfaces<ValueBoundsOpInterface,
-                            ConstantOp,
-                            ExtSIOp,
-                            AddIOp,
-                            SubIOp,
-                            MulIOp,
-                            SelectOp,
-                            FloorDivSIOp,
-                            CeilDivSIOp,
-                            MinSIOp,
-                            MaxSIOp,
-                            MinUIOp,
-                            MaxUIOp,
-                            RemSIOp,
-                            RemUIOp,
-                            DivUIOp,
-                            DivSIOp>();
+  declarePromisedInterfaces<ValueBoundsOpInterface, ConstantOp, ExtSIOp,
+                            AddIOp, SubIOp, MulIOp, SelectOp,
+                            FloorDivSIOp, CeilDivSIOp, MinSIOp,
+                            MaxSIOp, MinUIOp, MaxUIOp, RemSIOp, RemUIOp,
+                            DivUIOp, DivSIOp>();
   }
 
 /// Materialize an integer or floating point constant.

>From 215b920dd75ad62c08cc77dfbdb93f3a73eeb274 Mon Sep 17 00:00:00 2001
From: Hagai Lev Hacohen <hagai4000 at gmail.com>
Date: Tue, 30 Jun 2026 08:44:10 +0300
Subject: [PATCH 5/9] clang format

---
 mlir/lib/Dialect/Arith/IR/ArithDialect.cpp | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp b/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
index 7333d51f0a3df..50d2e25b68632 100644
--- a/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ArithDialect.cpp
@@ -55,11 +55,10 @@ void arith::ArithDialect::initialize() {
                            SelectOp>();
   declarePromisedInterfaces<bufferization::BufferizableOpInterface, ConstantOp,
                             IndexCastOp, SelectOp>();
-  declarePromisedInterfaces<ValueBoundsOpInterface, ConstantOp, ExtSIOp,
-                            AddIOp, SubIOp, MulIOp, SelectOp,
-                            FloorDivSIOp, CeilDivSIOp, MinSIOp,
-                            MaxSIOp, MinUIOp, MaxUIOp, RemSIOp, RemUIOp,
-                            DivUIOp, DivSIOp>();
+  declarePromisedInterfaces<ValueBoundsOpInterface, ConstantOp, ExtSIOp, AddIOp,
+                            SubIOp, MulIOp, SelectOp, FloorDivSIOp, CeilDivSIOp,
+                            MinSIOp, MaxSIOp, MinUIOp, MaxUIOp, RemSIOp,
+                            RemUIOp, DivUIOp, DivSIOp>();
   }
 
 /// Materialize an integer or floating point constant.

>From 35f75c9ee942442f9d67097a2f0879cc5d7b94dc Mon Sep 17 00:00:00 2001
From: Hagai Lev Hacohen <hagai4000 at gmail.com>
Date: Tue, 30 Jun 2026 11:27:05 +0300
Subject: [PATCH 6/9] added-bounds-for-the-general-case-in-divsi

---
 .../Arith/IR/ValueBoundsOpInterfaceImpl.cpp    |  9 +++++++--
 .../Arith/value-bounds-op-interface-impl.mlir  | 18 ++++++++++++++++++
 2 files changed, 25 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
index c7cd1b361f577..fde9667d874a1 100644
--- a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
@@ -103,11 +103,16 @@ struct DivSIOpInterface
         ValueBoundsConstraintSet::isProvablyPositive(rhsValue, cstr);
     bool rhsNegative =
         ValueBoundsConstraintSet::isProvablyNegative(rhsValue, cstr);
-    if ((!lhsNonNegative && !lhsNonPositive) || (!rhsPositive && !rhsNegative))
-      return;
 
     AffineExpr lhs = cstr.getExpr(lhsValue);
     AffineExpr rhs = cstr.getExpr(rhsValue);
+
+    cstr.bound(value) >= lhs.floorDiv(rhs);
+    cstr.bound(value) <= lhs.ceilDiv(rhs);
+
+    if ((!lhsNonNegative && !lhsNonPositive) || (!rhsPositive && !rhsNegative))
+      return;
+
     if ((lhsNonNegative && rhsPositive) || (lhsNonPositive && rhsNegative)) {
       cstr.bound(value) == lhs.floorDiv(rhs);
       cstr.bound(value) >= 0;
diff --git a/mlir/test/Dialect/Arith/value-bounds-op-interface-impl.mlir b/mlir/test/Dialect/Arith/value-bounds-op-interface-impl.mlir
index a0a4eb6120407..41f7f18baefec 100644
--- a/mlir/test/Dialect/Arith/value-bounds-op-interface-impl.mlir
+++ b/mlir/test/Dialect/Arith/value-bounds-op-interface-impl.mlir
@@ -195,6 +195,24 @@ func.func @arith_divsi_negative_lhs() -> index {
 
 // -----
 
+func.func @arith_divsi_unknown_lhs_constant_rhs(%a: index) {
+  %c5 = arith.constant 5 : index
+  %0 = arith.divsi %a, %c5 : index
+  // expected-remark @below{{true}}
+  "test.compare"(%0, %a) {
+      cmp = "GE",
+      rhs_map = affine_map<()[s0] -> (s0 floordiv 5)>
+  } : (index, index) -> ()
+  // expected-remark @below{{true}}
+  "test.compare"(%0, %a) {
+      cmp = "LE",
+      rhs_map = affine_map<()[s0] -> (s0 ceildiv 5)>
+  } : (index, index) -> ()
+  return
+}
+
+// -----
+
 // CHECK-LABEL: func @arith_remsi_positive_positive()
 //       CHECK:   %[[c0:.*]] = arith.constant 0 : index
 //       CHECK:   %[[c5:.*]] = arith.constant 5 : index

>From d358d4d9eb7869dcb804ccfbdeeaaec3a37f252a Mon Sep 17 00:00:00 2001
From: Hagai Lev Hacohen <hagai4000 at gmail.com>
Date: Tue, 30 Jun 2026 12:12:02 +0300
Subject: [PATCH 7/9] added-comments-and-removed-redundent-if

---
 mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
index fde9667d874a1..fb015f57f2e0f 100644
--- a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
@@ -107,12 +107,14 @@ struct DivSIOpInterface
     AffineExpr lhs = cstr.getExpr(lhsValue);
     AffineExpr rhs = cstr.getExpr(rhsValue);
 
+    // divsi rounds toward zero, unlike floorDiv/ceilDiv which round toward
+    // negative/positive infinity respectively. When the result is non-negative,
+    // divsi equals floorDiv(lhs, rhs); when negative, it equals ceilDiv(lhs, rhs).
+    // Without knowing the sign, bound the result between those two expressions.
     cstr.bound(value) >= lhs.floorDiv(rhs);
     cstr.bound(value) <= lhs.ceilDiv(rhs);
 
-    if ((!lhsNonNegative && !lhsNonPositive) || (!rhsPositive && !rhsNegative))
-      return;
-
+    // If the sign of the result is known, we can use the exact expression.
     if ((lhsNonNegative && rhsPositive) || (lhsNonPositive && rhsNegative)) {
       cstr.bound(value) == lhs.floorDiv(rhs);
       cstr.bound(value) >= 0;

>From 0316a46c4f9dcb24edc190d4cd0f2819ee9a7b3e Mon Sep 17 00:00:00 2001
From: Hagai Lev Hacohen <hagai4000 at gmail.com>
Date: Tue, 30 Jun 2026 12:16:15 +0300
Subject: [PATCH 8/9] clang format

---
 mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
index fb015f57f2e0f..b426cc43f1b27 100644
--- a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
@@ -109,8 +109,9 @@ struct DivSIOpInterface
 
     // divsi rounds toward zero, unlike floorDiv/ceilDiv which round toward
     // negative/positive infinity respectively. When the result is non-negative,
-    // divsi equals floorDiv(lhs, rhs); when negative, it equals ceilDiv(lhs, rhs).
-    // Without knowing the sign, bound the result between those two expressions.
+    // divsi equals floorDiv(lhs, rhs); when negative, it equals ceilDiv(lhs,
+    // rhs). Without knowing the sign, bound the result between those two
+    // expressions.
     cstr.bound(value) >= lhs.floorDiv(rhs);
     cstr.bound(value) <= lhs.ceilDiv(rhs);
 

>From eebc77b52e1536420d4327284c9934850fdea29e Mon Sep 17 00:00:00 2001
From: Hagai Lev Hacohen <hagai4000 at gmail.com>
Date: Tue, 30 Jun 2026 12:23:50 +0300
Subject: [PATCH 9/9] more documentation

---
 mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
index b426cc43f1b27..bc15d3b22f1b3 100644
--- a/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/Arith/IR/ValueBoundsOpInterfaceImpl.cpp
@@ -111,7 +111,7 @@ struct DivSIOpInterface
     // negative/positive infinity respectively. When the result is non-negative,
     // divsi equals floorDiv(lhs, rhs); when negative, it equals ceilDiv(lhs,
     // rhs). Without knowing the sign, bound the result between those two
-    // expressions.
+    // expressions, which is always correct.
     cstr.bound(value) >= lhs.floorDiv(rhs);
     cstr.bound(value) <= lhs.ceilDiv(rhs);
 



More information about the Mlir-commits mailing list