From 79e4530a9b7d3b15c1446bb02b1a0dfcd5e8fde1 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Sun, 1 Feb 2026 17:01:52 +0100 Subject: [PATCH] nir/opt_algebraic: make pattern pushing fmul into bcsel exact The only special case here is d == -0.0. Foz-DB Navi48: Totals from 3 (0.00% of 82405) affected shaders: CodeSize: 29140 -> 29188 (+0.16%) InvThroughput: 2945 -> 2951 (+0.20%) VALU: 3217 -> 3223 (+0.19%) Reviewed-by: Alyssa Rosenzweig Reviewed-by: Rhys Perry 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 0581243d15a..8a6b6bebb7f 100644 --- a/src/compiler/nir/nir_opt_algebraic.py +++ b/src/compiler/nir/nir_opt_algebraic.py @@ -532,8 +532,8 @@ optimizations.extend([ (('ffma@64(contract)', a, b, c), ('fadd', ('fmul', a, b), c), 'options->fuse_ffma64'), (('ffmaz(contract)', a, b, c), ('fadd', ('fmulz', a, b), c), 'options->fuse_ffma32'), - (('~fmul', ('fadd', ('bcsel', a, ('fmul', b, c), 0), '#d'), '#e'), - ('bcsel', a, ('fmul', ('fadd', ('fmul', b, c), d), e), ('fmul', d, e))), + (('fmul', ('fadd', ('bcsel', a, ('fmul', b, c), 0), '#d'), '#e'), + ('bcsel', a, ('fmul', ('fadd', ('fmul', b, c), d), e), ('fmul', ('fadd', d, 0.0), e))), (('fdph', a, b), ('fdot4', ('vec4', 'a.x', 'a.y', 'a.z', 1.0), b), 'options->lower_fdph'),