[Mlir-commits] [mlir] [mlir][arith] Add rounding mode flags to binary arithmetic operations (PR #188458)
Krzysztof Drewniak
llvmlistbot at llvm.org
Wed Apr 8 10:29:02 PDT 2026
================
@@ -957,14 +988,17 @@ def Arith_NegFOp : Arith_FloatUnaryOp<"negf"> {
// AddFOp
//===----------------------------------------------------------------------===//
-def Arith_AddFOp : Arith_FloatBinaryOp<"addf", [Commutative]> {
+def Arith_AddFOp : Arith_FloatBinaryOpWithRoundingMode<"addf", [Commutative]> {
let summary = "floating point addition operation";
let description = [{
The `addf` 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:
So my thought would be to go up into the `arith` documentation and describe the default floating point environment we use for internal purposes like constant-folding and note that this is the default used by LLVM, but observe that, as in many other languages (C, it looks like Vulkan) leaving the floating point rounding mode unspecified gives you whatever the platform default is.
So basically we'll be doing round-nearest-ties-to-even, no signalling NaNs, denormals enabled, etc. inside the `arith` dialect, but we're not going to promise that that's what'll happen post-export (because some targets don't make that promise either and it's fine, partly because everyone basically agrees anyway)
https://github.com/llvm/llvm-project/pull/188458
More information about the Mlir-commits
mailing list