[llvm] [WebAssembly] Lower fmuladd to fma (PR #161355)

Sam Parker via llvm-commits llvm-commits at lists.llvm.org
Fri Oct 3 00:56:24 PDT 2025


================
@@ -103,9 +136,8 @@ define <4 x float> @fmuladd_4xf32(<4 x float> %a, <4 x float> %b, <4 x float> %c
 ; RELAXED-LABEL: fmuladd_4xf32:
 ; RELAXED:         .functype fmuladd_4xf32 (v128, v128, v128) -> (v128)
 ; RELAXED-NEXT:  # %bb.0:
-; RELAXED-NEXT:    f32x4.mul $push0=, $0, $1
-; RELAXED-NEXT:    f32x4.add $push1=, $pop0, $2
----------------
sparker-arm wrote:

Yes, the ISD FMA follows the IEEE convention of rounding only once, so I understand the concern.

The key thing here is that we (backend developers) follow the semantics of the LLVM langref, which allows the fmuladd to either be lowered to a fused op or not, and obey the user.

Whether a fmuladd call is generated in the first place is determined by the language semantics, and frontend options provided by the user.

As noted by @dschuff [here](https://github.com/llvm/llvm-project/issues/55932#issuecomment-3285922007), for C/C++ the operations can be fused in a single statement, without providing additional flags to relax FP constraints.

WebAssembly adds a further restriction though because we only allow the fusing in the presence of relaxed-simd, and this is something that the user has to manually opt-in for. The user needs to understand that the precision of these operations are no longer deterministic when using relaxed-simd.

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


More information about the llvm-commits mailing list