[Mlir-commits] [mlir] [mlir][arith] Add rounding mode flags to binary arithmetic operations (PR #188458)

Krzysztof Drewniak llvmlistbot at llvm.org
Wed Mar 25 09:00:46 PDT 2026


================
@@ -988,14 +1022,17 @@ def Arith_AddFOp : Arith_FloatBinaryOp<"addf", [Commutative]> {
 // SubFOp
 //===----------------------------------------------------------------------===//
 
-def Arith_SubFOp : Arith_FloatBinaryOp<"subf"> {
+def Arith_SubFOp : Arith_FloatBinaryOpWithRoundingMode<"subf"> {
   let summary = "floating point subtraction operation";
   let description = [{
     The `subf` operation takes two operands and returns one result, each of
     these is required to be the same type. This type may be a floating point
     scalar type, a vector whose element type is a floating point type, or a
     floating point tensor.
 
+    If the value cannot be exactly represented, it is rounded using the
+    provided rounding mode or the default one if no rounding mode is provided.
----------------
krzysz00 wrote:

I'm not sure I agree with this.

I'd say that the lack of a rounding mode means that, in the absence of some sort of containing `arith.dynamic_fpenv` or `arith.strictfp` or such flag (maybe part of DLTI), we follow LLVM in assuming the default floating point environment - round-nearest-ties-to-even, no signalling NaNs, etc. - and can do constant evaluation and other transformations based on that assumption ... but do not guarantee that this will be the floating point environment present at runtime as that's backend/target dependent.

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


More information about the Mlir-commits mailing list