From ad421cdf2e68a1ccef80cb810c012c8469579cb6 Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Fri, 17 Oct 2025 10:38:10 +0200 Subject: [PATCH] nir: mark fneg distribution through fadd/ffma as nsz df1876f615a ("nir: Mark negative re-distribution on fadd as imprecise") fixed the fadd case by marking it as imprecise. This commit fixes the ffma case for the same reason. However, "imprecise" isn't necessary and nowadays we have "nsz" which is more accurate here. Use that for both fadd and ffma. Signed-off-by: Job Noorman Fixes: 62795475e8f ("nir/algebraic: Distribute source modifiers into instructions") Reviewed-by: Georg Lehmann Part-of: --- src/compiler/nir/nir_opt_algebraic.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/compiler/nir/nir_opt_algebraic.py b/src/compiler/nir/nir_opt_algebraic.py index 227faf60e45..e9a416a6a3e 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -4096,9 +4096,9 @@ distribute_src_mods = [ (('fneg', ('fmul(is_used_once)', a, b)), ('fmul', ('fneg', a), b)), (('fabs', ('fmul(is_used_once)', a, b)), ('fmul', ('fabs', a), ('fabs', b))), - (('fneg', ('ffma(is_used_once)', a, b, c)), ('ffma', ('fneg', a), b, ('fneg', c))), + (('fneg', ('ffma(is_used_once,nsz)', a, b, c)), ('ffma', ('fneg', a), b, ('fneg', c))), (('fneg', ('flrp(is_used_once)', a, b, c)), ('flrp', ('fneg', a), ('fneg', b), c)), - (('fneg', ('~fadd(is_used_once)', a, b)), ('fadd', ('fneg', a), ('fneg', b))), + (('fneg', ('fadd(is_used_once,nsz)', a, b)), ('fadd', ('fneg', a), ('fneg', b))), # Note that fmin <-> fmax. I don't think there is a way to distribute # fabs() into fmin or fmax.