From a60d61cce855cf053cbd290e399cc5991ddd1369 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Sat, 22 Mar 2025 16:05:10 +0100 Subject: [PATCH] nir: improve fadd is_a_number analysis by using the range Foz-DB Navi21: Totals from 145 (0.18% of 79789) affected shaders: Instrs: 168553 -> 168391 (-0.10%); split: -0.10%, +0.00% CodeSize: 926708 -> 926684 (-0.00%) Latency: 2210456 -> 2210329 (-0.01%); split: -0.01%, +0.00% InvThroughput: 545992 -> 545768 (-0.04%) SClause: 3084 -> 3085 (+0.03%) VALU: 129521 -> 129360 (-0.12%) SALU: 13085 -> 13084 (-0.01%) Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_range_analysis.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c index c52fbe01932..c1e3e1bcd80 100644 --- a/src/compiler/nir/nir_range_analysis.c +++ b/src/compiler/nir/nir_range_analysis.c @@ -551,9 +551,17 @@ fadd_is_a_number(const struct ssa_result_range left, const struct ssa_result_ran /* X + Y is NaN if either operand is NaN or if one operand is +Inf and * the other is -Inf. If neither operand is NaN and at least one of the * operands is finite, then the result cannot be NaN. + * If the combined range doesn't contain both postive and negative values + * (including Infs) then the result cannot be NaN either. */ + enum ssa_ranges combined_range = union_ranges(left.range, right.range); return left.is_a_number && right.is_a_number && - (left.is_finite || right.is_finite); + (left.is_finite || right.is_finite || + combined_range == eq_zero || + combined_range == gt_zero || + combined_range == ge_zero || + combined_range == lt_zero || + combined_range == le_zero); } /**