ir3: Lower ffma

OpenCL requires that ffma is fused, where fmad can be unfused.  Rusticl
will lower CL ffma for us, but that requires us to set .lower_ffmaN.
Late-opts will still re-fuse inexact fmul+fadd, since we are also
setting .fuse_ffmaN.

https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/37807#note_3215155
proposes separate ffma and fmad instructions for the two cases, which
would be a cleaner solution.

Signed-off-by: Rob Clark <rob.clark@oss.qualcomm.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40271>
This commit is contained in:
Rob Clark 2026-03-02 12:57:44 -08:00 committed by Marge Bot
parent c09d0018a3
commit ec18b2d28a

View file

@ -130,6 +130,16 @@ static const nir_shader_compiler_options ir3_base_options = {
.lower_usub_borrow = true,
.lower_mul_high = true,
.lower_mul_2x32_64 = true,
/* ir3's mad is an unfused mul-add instruction, so we need to flag fma
* lowering so that CL can implement fused fma in software. GLSL,
* SPIRV, and NIR don't require either fused or unfused behavior from
* fma, and we'll turn mul+adds back into nir_op_ffma (again, implemented
* as unfused) during nir_opt_algebraic_late() (assuming it's not
* decorated with GLSL's precise, or SPIRV's NoContraction).
*/
.lower_ffma16 = true,
.lower_ffma32 = true,
.lower_ffma64 = true,
.fuse_ffma16 = true,
.fuse_ffma32 = true,
.fuse_ffma64 = true,