From 1f3494b886b54a47dce14bd7b57b6cba826b08f4 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Fri, 14 Feb 2025 18:54:09 +0100 Subject: [PATCH] nir: range analysis for ffract Foz-DB Navi21: Totals from 75 (0.09% of 79377) affected shaders: Instrs: 69239 -> 68383 (-1.24%) CodeSize: 385088 -> 379532 (-1.44%) Latency: 427188 -> 421729 (-1.28%); split: -1.28%, +0.00% InvThroughput: 103086 -> 101926 (-1.13%) VClause: 785 -> 753 (-4.08%) SClause: 1624 -> 1598 (-1.60%) Copies: 5679 -> 5671 (-0.14%); split: -0.72%, +0.58% PreSGPRs: 3961 -> 3937 (-0.61%) VALU: 51107 -> 50457 (-1.27%) SALU: 9034 -> 8950 (-0.93%) VMEM: 1123 -> 1091 (-2.85%) SMEM: 2862 -> 2830 (-1.12%) Reviewed-by: Ian Romanick Part-of: --- src/compiler/nir/nir_range_analysis.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c index 6cc1fe00d99..80e43e7295d 100644 --- a/src/compiler/nir/nir_range_analysis.c +++ b/src/compiler/nir/nir_range_analysis.c @@ -600,6 +600,7 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 case nir_op_ffloor: case nir_op_fceil: case nir_op_ftrunc: + case nir_op_ffract: case nir_op_fdot2: case nir_op_fdot3: case nir_op_fdot4: @@ -1179,6 +1180,22 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 break; } + case nir_op_ffract: { + const struct ssa_result_range left = unpack_data(src_res[0]); + + /* fract(±Inf) is NaN */ + r.is_a_number = left.is_a_number && left.is_finite; + r.is_integral = left.is_integral; + r.is_finite = r.is_a_number; + + if (left.is_integral || left.range == eq_zero) + r.range = eq_zero; + else + r.range = ge_zero; + + break; + } + case nir_op_flt: case nir_op_fge: case nir_op_feq: