[Mlir-commits] [mlir] [TOSA] Prevent OoB accesses in gather/scatter (PR #213242)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Fri Jul 31 03:52:58 PDT 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/Conversion/TosaToLinalg/TosaToLinalg.cpp mlir/lib/Conversion/TosaToSCF/TosaToSCF.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/Conversion/TosaToLinalg/TosaToLinalg.cpp b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
index 425dea8c0..eb0b64830 100644
--- a/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
+++ b/mlir/lib/Conversion/TosaToLinalg/TosaToLinalg.cpp
@@ -2561,9 +2561,9 @@ public:
           auto index0 = linalg::IndexOp::create(rewriter, loc, 0);
           Value index1 = arith::IndexCastOp::create(
               rewriter, loc, rewriter.getIndexType(), indexValue);
-          auto outOfBound = arith::CmpIOp::create(
-              rewriter, loc, rewriter.getI1Type(), arith::CmpIPredicate::uge,
-              index1, kSzVal);
+          auto outOfBound =
+              arith::CmpIOp::create(rewriter, loc, rewriter.getI1Type(),
+                                    arith::CmpIPredicate::uge, index1, kSzVal);
           index1 =
               arith::SelectOp::create(rewriter, loc, rewriter.getIndexType(),
                                       outOfBound, kSzVal, index1);
diff --git a/mlir/lib/Conversion/TosaToSCF/TosaToSCF.cpp b/mlir/lib/Conversion/TosaToSCF/TosaToSCF.cpp
index c8c1897fa..4b4db6871 100644
--- a/mlir/lib/Conversion/TosaToSCF/TosaToSCF.cpp
+++ b/mlir/lib/Conversion/TosaToSCF/TosaToSCF.cpp
@@ -130,12 +130,11 @@ public:
       auto index = tensor::ExtractOp::create(builder, loc, indices, ivs);
       auto castIndex = arith::IndexCastOp::create(
           builder, loc, builder.getIndexType(), index);
-      auto outOfBound = arith::CmpIOp::create(
-          builder, loc, builder.getI1Type(), arith::CmpIPredicate::uge,
-          castIndex, kSzVal);
-      auto clampedIndex =
-          arith::SelectOp::create(builder, loc, builder.getIndexType(),
-                                  outOfBound, kSzVal, castIndex);
+      auto outOfBound =
+          arith::CmpIOp::create(builder, loc, builder.getI1Type(),
+                                arith::CmpIPredicate::uge, castIndex, kSzVal);
+      auto clampedIndex = arith::SelectOp::create(
+          builder, loc, builder.getIndexType(), outOfBound, kSzVal, castIndex);
 
       // Offset, sizes, and strides for the input tensor
       auto inputOffset = llvm::to_vector(ivs);

``````````

</details>


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


More information about the Mlir-commits mailing list