nir: remove more fsat using range analysis

Foz-DB Navi48:
Totals from 3018 (3.65% of 82636) affected shaders:
MaxWaves: 69274 -> 69280 (+0.01%)
Instrs: 7165414 -> 7157581 (-0.11%); split: -0.12%, +0.01%
CodeSize: 38890212 -> 38823132 (-0.17%); split: -0.18%, +0.00%
VGPRs: 228672 -> 228624 (-0.02%)
Latency: 64789026 -> 64784877 (-0.01%); split: -0.01%, +0.00%
InvThroughput: 11805156 -> 11802642 (-0.02%); split: -0.02%, +0.00%
VClause: 136900 -> 136886 (-0.01%); split: -0.03%, +0.02%
SClause: 150135 -> 150130 (-0.00%); split: -0.01%, +0.01%
Copies: 574690 -> 574894 (+0.04%); split: -0.03%, +0.06%
Branches: 187169 -> 187086 (-0.04%); split: -0.04%, +0.00%
PreSGPRs: 190074 -> 190067 (-0.00%); split: -0.00%, +0.00%
PreVGPRs: 189564 -> 189538 (-0.01%); split: -0.02%, +0.00%
VALU: 3955188 -> 3949411 (-0.15%); split: -0.15%, +0.00%
SALU: 1114659 -> 1114729 (+0.01%); split: -0.02%, +0.03%
SMEM: 231080 -> 231077 (-0.00%); split: -0.00%, +0.00%
VOPD: 116150 -> 116180 (+0.03%); split: +0.04%, -0.02%

Reviewed-by: Alyssa Rosenzweig <alyssa.rosenzweig@intel.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/39987>
This commit is contained in:
Georg Lehmann 2026-02-12 16:50:26 +01:00 committed by Marge Bot
parent 506bb5a609
commit 4885e5cf3a
2 changed files with 6 additions and 4 deletions

View file

@ -1055,10 +1055,11 @@ optimizations.extend([
# fmin(0.0, b)) while the right one is "b", so this optimization is not NaN correct.
(('fmin(nsz)', ('fsat(nnan)', a), '#b(is_zero_to_one)'), ('fsat', ('fmin', a, b))),
# If a >= 0 ... 1 + a >= 1 ... so fsat(1 + a) = 1
# But 1 + NaN is NaN and fsat(NaN) = 0.
(('fsat(nnan)', ('fadd', 1.0, 'a(is_not_negative)')), 1.0),
(('fsat', ('fadd', 1.0, 'a(is_a_number_not_negative)')), 1.0),
(('fsat(nnan)', 'a(is_ge_pos_one)'), 1.0),
(('fsat', 'a(is_a_number_ge_pos_one)'), 1.0),
(('fsat(nnan,nsz)', 'a(is_zero_to_one)'), ('fcanonicalize', a)),
(('fsat(nsz)', 'a(is_a_number_zero_to_one)'), ('fcanonicalize', a)),
# Let constant folding do its job. This can have emergent behaviour.
(('fneg', ('bcsel(is_used_once)', a, '#b', '#c')), ('bcsel', a, ('fneg', b), ('fneg', c))),

View file

@ -875,6 +875,7 @@ RELATION_AND_NUM(not_zero, FP_CLASS_ANY_ZERO)
RELATION_AND_NUM(zero_to_one, FP_CLASS_ANY_NEG | FP_CLASS_GT_POS_ONE | FP_CLASS_POS_INF)
RELATION_AND_NUM(le_pos_one, FP_CLASS_GT_POS_ONE | FP_CLASS_POS_INF)
RELATION_AND_NUM(gt_0_and_lt_1, FP_CLASS_ANY_NEG | FP_CLASS_ANY_ZERO | FP_CLASS_POS_ONE | FP_CLASS_GT_POS_ONE | FP_CLASS_POS_INF)
RELATION_AND_NUM(ge_pos_one, FP_CLASS_ANY_NEG | FP_CLASS_ANY_ZERO | FP_CLASS_GT_ZERO_LT_POS_ONE)
RELATION(a_number, FP_CLASS_NAN)
RELATION(finite, FP_CLASS_ANY_INF | FP_CLASS_NAN)
RELATION(finite_not_zero, FP_CLASS_ANY_INF | FP_CLASS_NAN | FP_CLASS_ANY_ZERO)