nir/opt_algebraic: optimize more near useless bcsel

Foz-DB Navi48:
Totals from 327 (0.29% of 114655) affected shaders:
Instrs: 732971 -> 731642 (-0.18%); split: -0.19%, +0.01%
CodeSize: 3696020 -> 3689824 (-0.17%); split: -0.17%, +0.00%
Latency: 4405319 -> 4403413 (-0.04%); split: -0.06%, +0.01%
InvThroughput: 650209 -> 649659 (-0.08%); split: -0.10%, +0.01%
Copies: 53872 -> 53736 (-0.25%); split: -0.27%, +0.02%
Branches: 15598 -> 15571 (-0.17%)
VALU: 262391 -> 261969 (-0.16%)
SALU: 268112 -> 267699 (-0.15%)

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/40399>
This commit is contained in:
Georg Lehmann 2026-03-13 14:39:46 +01:00 committed by Marge Bot
parent 6cfe6eaa79
commit b96c42c916

View file

@ -783,8 +783,12 @@ optimizations.extend([
# 0 < fsat(NaN) -> 0 < 0 -> false, and 0 < NaN -> false.
(('flt', 0.0, ('fsat(is_used_once)', a)), ('flt', 0.0, a)),
(('bcsel(is_only_used_as_float)', ('feq', a, 'b(is_not_zero)'), b, a), a),
(('bcsel(is_only_used_as_float)', ('fneu', a, 'b(is_not_zero)'), a, b), a),
(('bcsel', ('feq', a, 'b(is_a_number_not_zero)'), b, a), a),
(('bcsel', ('fneu', a, 'b(is_a_number_not_zero)'), a, b), a),
(('bcsel(is_only_used_as_float_nsz)', ('feq', a, 0.0), 0.0, a), a),
(('bcsel(is_only_used_as_float_nsz)', ('fneu', a, 0.0), a, 0.0), a),
(('bcsel(is_only_used_as_float_nsz)', ('feq', a, 0.0), -0.0, a), a),
(('bcsel(is_only_used_as_float_nsz)', ('fneu', a, 0.0), a, -0.0), a),
(('bcsel', ('feq', a, 0), 0, ('fsat', ('fmul', a, 'b(is_a_number)'))), ('fsat(preserve_sz)', ('fmul', a, b))),
(('bcsel', ('fneu', a, 0), ('fsat', ('fmul', a, 'b(is_a_number)')), 0), ('fsat(preserve_sz)', ('fmul', a, b))),
(('bcsel', ('feq', a, 0), b, ('fadd', a, 'b(is_not_zero)')), ('fadd', a, b)),