[Mlir-commits] [mlir] [mlir][ArmSME][NFC] Improving the readability of outer product fusion (PR #227140)

Federico Bruzzone llvmlistbot at llvm.org
Sun Oct 4 15:26:00 PDT 2026


https://github.com/FedericoBruzzone updated https://github.com/llvm/llvm-project/pull/227140

>From ab0c8071103261d13967022b7b215218d8dd54b3 Mon Sep 17 00:00:00 2001
From: Federico Bruzzone <federico.bruzzone.i at gmail.com>
Date: Tue, 29 Sep 2026 00:26:56 +0200
Subject: [PATCH 1/2] [mlir][ArmSME][NFC] Improving the readability of
 outerproduct fusion

Signed-off-by: Federico Bruzzone <federico.bruzzone.i at gmail.com>
---
 .../ArmSME/Transforms/OuterProductFusion.cpp  | 39 +++++++++++--------
 1 file changed, 23 insertions(+), 16 deletions(-)

diff --git a/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp b/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
index f1c36edac6094..a8369543a6466 100644
--- a/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
+++ b/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
@@ -219,22 +219,29 @@ class OuterProductFusion2Way
     auto nxv4i16 = VectorType::get({4}, rewriter.getI16Type(), true);
     auto nxv4f16 = VectorType::get({4}, rewriter.getF16Type(), true);
     auto nxv4bf16 = VectorType::get({4}, rewriter.getBF16Type(), true);
-    if ((failed(
-             isCompatible<arith::ExtFOp>(rewriter, op1, nxnxv4f32, nxv4f16)) ||
-         failed(
-             isCompatible<arith::ExtFOp>(rewriter, op2, nxnxv4f32, nxv4f16))) &&
-        (failed(
-             isCompatible<arith::ExtFOp>(rewriter, op1, nxnxv4f32, nxv4bf16)) ||
-         failed(isCompatible<arith::ExtFOp>(rewriter, op2, nxnxv4f32,
-                                            nxv4bf16))) &&
-        (failed(
-             isCompatible<arith::ExtSIOp>(rewriter, op1, nxnxv4i32, nxv4i16)) ||
-         failed(isCompatible<arith::ExtSIOp>(rewriter, op2, nxnxv4i32,
-                                             nxv4i16))) &&
-        (failed(
-             isCompatible<arith::ExtUIOp>(rewriter, op1, nxnxv4i32, nxv4i16)) ||
-         failed(
-             isCompatible<arith::ExtUIOp>(rewriter, op2, nxnxv4i32, nxv4i16))))
+    const bool isF16Compatible =
+        succeeded(
+            isCompatible<arith::ExtFOp>(rewriter, op1, nxnxv4f32, nxv4f16)) &&
+        succeeded(
+            isCompatible<arith::ExtFOp>(rewriter, op2, nxnxv4f32, nxv4f16));
+    const bool isBF16Compatible =
+        succeeded(
+            isCompatible<arith::ExtFOp>(rewriter, op1, nxnxv4f32, nxv4bf16)) &&
+        succeeded(
+            isCompatible<arith::ExtFOp>(rewriter, op2, nxnxv4f32, nxv4bf16));
+    const bool isI16Compatible =
+        succeeded(
+            isCompatible<arith::ExtSIOp>(rewriter, op1, nxnxv4i32, nxv4i16)) &&
+        succeeded(
+            isCompatible<arith::ExtSIOp>(rewriter, op2, nxnxv4i32, nxv4i16));
+    const bool isUI16Compatible =
+        succeeded(
+            isCompatible<arith::ExtUIOp>(rewriter, op1, nxnxv4i32, nxv4i16)) &&
+        succeeded(
+            isCompatible<arith::ExtUIOp>(rewriter, op2, nxnxv4i32, nxv4i16));
+
+    if (!isF16Compatible && !isBF16Compatible && !isI16Compatible &&
+        !isUI16Compatible)
       return failure();
 
     return success();

>From 6f10481179e9a9264bde1b8706009d991164bceb Mon Sep 17 00:00:00 2001
From: Federico Bruzzone <federico.bruzzone.i at gmail.com>
Date: Mon, 5 Oct 2026 00:25:34 +0200
Subject: [PATCH 2/2] Address nit

Signed-off-by: Federico Bruzzone <federico.bruzzone.i at gmail.com>
---
 .../lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp | 9 ++++-----
 1 file changed, 4 insertions(+), 5 deletions(-)

diff --git a/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp b/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
index a8369543a6466..a8b89f9157a70 100644
--- a/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
+++ b/mlir/lib/Dialect/ArmSME/Transforms/OuterProductFusion.cpp
@@ -240,11 +240,10 @@ class OuterProductFusion2Way
         succeeded(
             isCompatible<arith::ExtUIOp>(rewriter, op2, nxnxv4i32, nxv4i16));
 
-    if (!isF16Compatible && !isBF16Compatible && !isI16Compatible &&
-        !isUI16Compatible)
-      return failure();
-
-    return success();
+    return (isF16Compatible || isBF16Compatible || isI16Compatible ||
+            isUI16Compatible)
+               ? success()
+               : failure();
   }
 };
 



More information about the Mlir-commits mailing list