[Mlir-commits] [mlir] [MLIR][Math] Enable strict property assembly format (PR #217275)
Mehdi Amini
llvmlistbot at llvm.org
Wed Aug 19 03:51:39 PDT 2026
https://github.com/joker-eph updated https://github.com/llvm/llvm-project/pull/217275
>From 96caaf572b2e2153378151933526b2fdf75f7ad5 Mon Sep 17 00:00:00 2001
From: Mehdi Amini <joker.eph at gmail.com>
Date: Wed, 6 May 2026 13:39:26 -0700
Subject: [PATCH] [MLIR][Math] Enable strict property assembly format
Enable the strict properties assembly format mode for the Math dialect.
Spell the classification fast-math attribute in the declarative format so
it is not parsed from attr-dict in strict mode.
Assisted-by: Codex
---
mlir/include/mlir/Dialect/Math/IR/MathBase.td | 1 +
mlir/include/mlir/Dialect/Math/IR/MathOps.td | 3 ++-
mlir/test/Dialect/Math/ops.mlir | 8 ++++++++
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/mlir/include/mlir/Dialect/Math/IR/MathBase.td b/mlir/include/mlir/Dialect/Math/IR/MathBase.td
index 19fb39d9fd51d..162284a1d8363 100644
--- a/mlir/include/mlir/Dialect/Math/IR/MathBase.td
+++ b/mlir/include/mlir/Dialect/Math/IR/MathBase.td
@@ -10,6 +10,7 @@
include "mlir/IR/OpBase.td"
def Math_Dialect : Dialect {
let name = "math";
+ let useStrictPropertiesInAssemblyFormat = 1;
let cppNamespace = "::mlir::math";
let description = [{
The math dialect is intended to hold mathematical operations on integer and
diff --git a/mlir/include/mlir/Dialect/Math/IR/MathOps.td b/mlir/include/mlir/Dialect/Math/IR/MathOps.td
index 926bac1de2b0d..5debb3c57a319 100644
--- a/mlir/include/mlir/Dialect/Math/IR/MathOps.td
+++ b/mlir/include/mlir/Dialect/Math/IR/MathOps.td
@@ -48,7 +48,8 @@ class Math_FloatClassificationOp<string mnemonic, list<Trait> traits = []> :
"::mlir::arith::FastMathFlags::none">:$fastmath);
let results = (outs BoolLike:$result);
- let assemblyFormat = "$operand attr-dict `:` type($operand)";
+ let assemblyFormat = [{ $operand (`fastmath` `` $fastmath^)?
+ attr-dict `:` type($operand) }];
}
// Base class for unary math operations on floating point types. Require an
diff --git a/mlir/test/Dialect/Math/ops.mlir b/mlir/test/Dialect/Math/ops.mlir
index b33f3d1eeea97..e7068bece3c61 100644
--- a/mlir/test/Dialect/Math/ops.mlir
+++ b/mlir/test/Dialect/Math/ops.mlir
@@ -329,6 +329,8 @@ func.func @fpclassify(%f: f32, %d: f64, %v: vector<4xf32>, %t: tensor<4x?xf32>)
math.isfinite %d : f64
math.isfinite %v : vector<4xf32>
math.isfinite %t : tensor<4x?xf32>
+ // CHECK: math.isfinite %[[F]] fastmath<nnan> : f32
+ math.isfinite %f fastmath<nnan> : f32
// CHECK: math.isinf %[[F]] : f32
// CHECK: math.isinf %[[D]] : f64
// CHECK: math.isinf %[[V]] : vector<4xf32>
@@ -337,6 +339,8 @@ func.func @fpclassify(%f: f32, %d: f64, %v: vector<4xf32>, %t: tensor<4x?xf32>)
math.isinf %d : f64
math.isinf %v : vector<4xf32>
math.isinf %t : tensor<4x?xf32>
+ // CHECK: math.isinf %[[D]] fastmath<ninf> : f64
+ math.isinf %d fastmath<ninf> : f64
// CHECK: math.isnan %[[F]] : f32
// CHECK: math.isnan %[[D]] : f64
// CHECK: math.isnan %[[V]] : vector<4xf32>
@@ -345,6 +349,8 @@ func.func @fpclassify(%f: f32, %d: f64, %v: vector<4xf32>, %t: tensor<4x?xf32>)
math.isnan %d : f64
math.isnan %v : vector<4xf32>
math.isnan %t : tensor<4x?xf32>
+ // CHECK: math.isnan %[[V]] fastmath<nnan> : vector<4xf32>
+ math.isnan %v fastmath<nnan> : vector<4xf32>
// CHECK: math.isnormal %[[F]] : f32
// CHECK: math.isnormal %[[D]] : f64
// CHECK: math.isnormal %[[V]] : vector<4xf32>
@@ -353,6 +359,8 @@ func.func @fpclassify(%f: f32, %d: f64, %v: vector<4xf32>, %t: tensor<4x?xf32>)
math.isnormal %d : f64
math.isnormal %v : vector<4xf32>
math.isnormal %t : tensor<4x?xf32>
+ // CHECK: math.isnormal %[[T]] fastmath<fast> : tensor<4x?xf32>
+ math.isnormal %t fastmath<fast> : tensor<4x?xf32>
return
}
More information about the Mlir-commits
mailing list