From 73bce23f656ca8397fcf2d330bff3213ee9f2048 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Wed, 11 Feb 2026 19:58:41 +0100 Subject: [PATCH] nir: add fp class analysis for flog2 Foz-DB Navi48: Totals from 230 (0.28% of 82636) affected shaders: Instrs: 599005 -> 598615 (-0.07%); split: -0.09%, +0.02% CodeSize: 3110528 -> 3103136 (-0.24%); split: -0.24%, +0.00% Latency: 3661526 -> 3663241 (+0.05%); split: -0.01%, +0.05% InvThroughput: 526561 -> 526487 (-0.01%); split: -0.01%, +0.00% Copies: 33735 -> 33820 (+0.25%); split: -0.06%, +0.31% VALU: 378034 -> 377904 (-0.03%); split: -0.03%, +0.00% SALU: 65156 -> 65045 (-0.17%); split: -0.19%, +0.02% Reviewed-by: Alyssa Rosenzweig Part-of: --- src/compiler/nir/nir_range_analysis.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c index cab31b12db1..4dd7926d661 100644 --- a/src/compiler/nir/nir_range_analysis.c +++ b/src/compiler/nir/nir_range_analysis.c @@ -735,6 +735,7 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 case nir_op_mov: case nir_op_fabs: case nir_op_fexp2: + case nir_op_flog2: case nir_op_frcp: case nir_op_fsqrt: case nir_op_frsq: @@ -931,6 +932,29 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 break; } + case nir_op_flog2: { + r = 0; + + if (src_res[0] & (FP_CLASS_ANY_NEG | FP_CLASS_NAN)) + r |= FP_CLASS_NAN; + + if (src_res[0] & FP_CLASS_ANY_ZERO) + r |= FP_CLASS_NEG_INF; + + if (src_res[0] & FP_CLASS_GT_ZERO_LT_POS_ONE) + r |= FP_CLASS_ANY_NEG | FP_CLASS_NON_INTEGRAL; + + if (src_res[0] & FP_CLASS_POS_ONE) + r |= FP_CLASS_POS_ZERO; + + if (src_res[0] & FP_CLASS_GT_POS_ONE) + r |= FP_CLASS_GT_ZERO_LT_POS_ONE | FP_CLASS_POS_ONE | FP_CLASS_GT_POS_ONE | FP_CLASS_NON_INTEGRAL; + + if (src_res[0] & FP_CLASS_POS_INF) + r |= FP_CLASS_POS_INF; + break; + } + case nir_op_fmax: { fp_class_mask left = fneg_fp_class(src_res[0]); fp_class_mask right = fneg_fp_class(src_res[1]);