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 <alyssa@rosenzweig.io>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/34125>
This commit is contained in:
Georg Lehmann 2025-03-22 16:05:10 +01:00 committed by Marge Bot
parent a6fd9f488a
commit a60d61cce8

View file

@ -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);
}
/**