[Mlir-commits] [mlir] [mlir][memref]: Added OOB value bound check to ViewOp (PR #183985)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sat Feb 28 23:42:16 PST 2026


github-actions[bot] wrote:

<!--LLVM CODE FORMAT COMMENT: {clang-format}-->


:warning: C/C++ code formatter, clang-format found issues in your code. :warning:

<details>
<summary>
You can test this locally with the following command:
</summary>

``````````bash
git-clang-format --diff origin/main HEAD --extensions cpp -- mlir/lib/Dialect/MemRef/IR/ValueBoundsOpInterfaceImpl.cpp --diff_from_common_commit
``````````

:warning:
The reproduction instructions above might return results for more than one PR
in a stack if you are using a stacked PR workflow. You can limit the results by
changing `origin/main` to the base branch/commit you want to compare against.
:warning:

</details>

<details>
<summary>
View the diff from clang-format here.
</summary>

``````````diff
diff --git a/mlir/lib/Dialect/MemRef/IR/ValueBoundsOpInterfaceImpl.cpp b/mlir/lib/Dialect/MemRef/IR/ValueBoundsOpInterfaceImpl.cpp
index 6d4c2e474..9772e04b0 100644
--- a/mlir/lib/Dialect/MemRef/IR/ValueBoundsOpInterfaceImpl.cpp
+++ b/mlir/lib/Dialect/MemRef/IR/ValueBoundsOpInterfaceImpl.cpp
@@ -154,10 +154,10 @@ struct ViewOpInterface
     cstr.bound(value)[dim] == viewOp.getMixedSizes()[dim];
 
     // Out-of-bounds constraint in bytes.
-    // The total number of bytes in the result should be the product of all result dimensions according to the element type size.
-    // Therefore, the out-of-bounds constraint in bytes is:
-    // (src_bytes - byte_shift) / dim_size == total_result_bytes_without_dim
-    // meaning that:
+    // The total number of bytes in the result should be the product of all
+    // result dimensions according to the element type size. Therefore, the
+    // out-of-bounds constraint in bytes is: (src_bytes - byte_shift) / dim_size
+    // == total_result_bytes_without_dim meaning that:
     //  dim_size == (src_bytes - byte_shift) / total_result_bytes_without_dim
     AffineExpr sourceBytes = cstr.getExpr(viewOp.getSource(), 0);
     AffineExpr byteShift = cstr.getExpr(viewOp.getByteShift());
@@ -169,9 +169,11 @@ struct ViewOpInterface
     AffineExpr totalResultBytesWithoutDim = cstr.getExpr(elementSizeBytes);
     for (unsigned i = 0; i < viewOp.getType().getRank(); ++i)
       if (i != dim)
-        totalResultBytesWithoutDim = totalResultBytesWithoutDim * cstr.getExpr(value, i);
+        totalResultBytesWithoutDim =
+            totalResultBytesWithoutDim * cstr.getExpr(value, i);
 
-    cstr.bound(value)[dim] == availableBytes.floorDiv(totalResultBytesWithoutDim);
+    cstr.bound(value)[dim] ==
+        availableBytes.floorDiv(totalResultBytesWithoutDim);
   }
 };
 

``````````

</details>


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


More information about the Mlir-commits mailing list