[Mlir-commits] [mlir] [MLIR][Arith] Add denormal attribute to binary/unary operations (PR #112700)

Jakub Kuderski llvmlistbot at llvm.org
Thu Nov 21 11:10:10 PST 2024


================
@@ -181,4 +181,38 @@ def Arith_RoundingModeAttr : I32EnumAttr<
   let cppNamespace = "::mlir::arith";
 }
 
+//===----------------------------------------------------------------------===//
+// Arith_DenormalMode
+//===----------------------------------------------------------------------===//
+
+// Denormal mode is applied on operands and results. For example, if denormal =
+// preserve_sign, operands and results will be flushed to sign preserving zero.
+// We do not distinguish between operands and results.
+
+// The default mode. Denormals are preserved and processed as defined 
+// by IEEE 754 rules.
+def Arith_DenormalModeIEEE          : I32BitEnumAttrCaseNone<"ieee">;
+
+// A mode where denormal numbers are flushed to zero, but the sign of the zero 
+// (+0 or -0) is preserved.
+def Arith_DenormalModePreserveSign  : I32BitEnumAttrCase<"preserve_sign", 1>;
+
+// A mode where all denormal numbers are flushed to positive zero (+0), 
+// ignoring the sign of the original number.
+def Arith_DenormalModePositiveZero  : I32BitEnumAttrCase<"positive_zero",  2>;
+
+def Arith_DenormalMode : I32BitEnumAttr<
----------------
kuhar wrote:

Do we need more than one bit set at a time? If not, this should be a plain `I32EnumAttr`.

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


More information about the Mlir-commits mailing list