[Mlir-commits] [mlir] [mlir][Vector] add vector.insert canonicalization pattern for vectors created from ub.poison (PR #142944)

llvmlistbot at llvm.org llvmlistbot at llvm.org
Sun Aug 3 21:22:20 PDT 2025


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 HEAD~1 HEAD --extensions cpp -- mlir/lib/Dialect/Vector/IR/VectorOps.cpp
``````````

</details>

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

``````````diff
diff --git a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
index 7b2826b09..4484cbf7a 100644
--- a/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
+++ b/mlir/lib/Dialect/Vector/IR/VectorOps.cpp
@@ -3390,21 +3390,21 @@ public:
                                  pendingInsertValues))) {
       auto srcVectorType =
               llvm::dyn_cast<VectorType>(valueToStore.getType()));
-              
-       if (!srcVectorType) {
-         elements[insertBeginPosition] = valueToStore;
-         continue;
-       }
-       
-        SmallVector<Type> elementToInsertTypes(insertSize,
-                                               srcVectorType.getElementType());
-        auto elementsToInsert = rewriter.create<vector::ToElementsOp>(
-            op.getLoc(), elementToInsertTypes, valueToStore);
-        // Get all elements from the vector in row-major order.
-        for (int64_t linearIdx = 0; linearIdx < insertSize; linearIdx++) {
-          elements[insertBeginPosition + linearIdx] =
-              elementsToInsert.getResult(linearIdx);
-        }
+
+      if (!srcVectorType) {
+        elements[insertBeginPosition] = valueToStore;
+        continue;
+      }
+
+      SmallVector<Type> elementToInsertTypes(insertSize,
+                                             srcVectorType.getElementType());
+      auto elementsToInsert = rewriter.create<vector::ToElementsOp>(
+          op.getLoc(), elementToInsertTypes, valueToStore);
+      // Get all elements from the vector in row-major order.
+      for (int64_t linearIdx = 0; linearIdx < insertSize; linearIdx++) {
+        elements[insertBeginPosition + linearIdx] =
+            elementsToInsert.getResult(linearIdx);
+      }
     }
 
     rewriter.replaceOpWithNewOp<vector::FromElementsOp>(op, destTy, elements);

``````````

</details>


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


More information about the Mlir-commits mailing list