[Mlir-commits] [mlir] [mlir][math] Add VectorDialect dependency to MathToAPFloatConversion (PR #206212)
Longsheng Mou
llvmlistbot at llvm.org
Fri Jun 26 18:58:08 PDT 2026
https://github.com/CoTinker created https://github.com/llvm/llvm-project/pull/206212
Explicitly load VectorDialect as a dependent dialect in MathToAPFloatConversionPass to avoid unregistered dialect errors when generating vector ops. Fixes #206093.
>From 1c0c70e4f28b69c2597043474506d9682b973868 Mon Sep 17 00:00:00 2001
From: Longsheng Mou <longshengmou at gmail.com>
Date: Sat, 27 Jun 2026 09:55:20 +0800
Subject: [PATCH 1/2] [mlir][math] Add VectorDialect dependency to
MathToAPFloatConversion
Explicitly load VectorDialect as a dependent dialect in MathToAPFloatConversionPass to avoid unregistered dialect errors when generating vector ops.
---
mlir/include/mlir/Conversion/Passes.td | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/mlir/include/mlir/Conversion/Passes.td b/mlir/include/mlir/Conversion/Passes.td
index 340ff8fdf2a8a..b92bc1cd31723 100644
--- a/mlir/include/mlir/Conversion/Passes.td
+++ b/mlir/include/mlir/Conversion/Passes.td
@@ -828,7 +828,11 @@ def MathToAPFloatConversionPass
calls (APFloatWrappers.cpp). APFloat is a software implementation of
floating-point mathmetic operations.
}];
- let dependentDialects = ["math::MathDialect", "func::FuncDialect"];
+ let dependentDialects = [
+ "math::MathDialect",
+ "func::FuncDialect",
+ "vector::VectorDialect"
+ ];
}
//===----------------------------------------------------------------------===//
>From 62722c4f2ae54040c2c643d426d2c61918e4b1cf Mon Sep 17 00:00:00 2001
From: Longsheng Mou <longshengmou at gmail.com>
Date: Sat, 27 Jun 2026 09:56:52 +0800
Subject: [PATCH 2/2] add test
---
.../ArithAndMathToAPFloat/math-to-apfloat.mlir | 16 +++++++++++++++-
1 file changed, 15 insertions(+), 1 deletion(-)
diff --git a/mlir/test/Conversion/ArithAndMathToAPFloat/math-to-apfloat.mlir b/mlir/test/Conversion/ArithAndMathToAPFloat/math-to-apfloat.mlir
index e52eb5866093c..2fe1d0cda1e38 100644
--- a/mlir/test/Conversion/ArithAndMathToAPFloat/math-to-apfloat.mlir
+++ b/mlir/test/Conversion/ArithAndMathToAPFloat/math-to-apfloat.mlir
@@ -1,4 +1,4 @@
-// RUN: mlir-opt %s --convert-math-to-apfloat | FileCheck %s
+// RUN: mlir-opt %s --convert-math-to-apfloat -split-input-file | FileCheck %s
func.func @full_example() {
%neg14fp8 = arith.constant -1.4 : f8E4M3FN
@@ -64,3 +64,17 @@ func.func @full_example() {
// CHECK: %[[VAL_5:.*]] = call @_mlir_apfloat_isfinite(%[[CONSTANT_9]], %[[EXTUI_7]]) : (i32, i64) -> i1
// CHECK: return
// CHECK: }
+
+// -----
+
+// Ensure the Vector dialect is registered.
+
+// CHECK-LABEL: func @test_vector(
+// CHECK: vector.to_elements
+func.func @test_vector() {
+ %a1_vec = arith.constant dense<[2.0, 2.0, 2.0, 2.0]> : vector<4xf8E4M3FN>
+ %b1_vec = arith.constant dense<[4.0, 4.0, 4.0, 4.0]> : vector<4xf8E4M3FN>
+ %c1_vec = arith.constant dense<[8.0, 8.0, 8.0, 8.0]> : vector<4xf8E4M3FN>
+ %d1_vec = math.fma %a1_vec, %b1_vec, %c1_vec : vector<4xf8E4M3FN>
+ return
+}
More information about the Mlir-commits
mailing list