From 4799e79a5fee5ddaeed5fe68f79e60aa7ebd9e66 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Mon, 27 Apr 2026 09:18:05 +0200 Subject: [PATCH] nir: disable fp class analysis for 64bit transcendentals Some backends have terrible precision for these fp64 opcodes, so don't try to do anything clever. Closes: https://gitlab.freedesktop.org/mesa/mesa/-/work_items/15334 Fixes: 5a298f35606 ("nir: rewrite fp range analysis as a fp class analysis") Reviewed-by: Alyssa Rosenzweig Reviewed-by: Eric R. Smith (cherry picked from commit 599a52174b407ac4ad377b4d6f0e95c62218cdff) Part-of: --- .pick_status.json | 2 +- src/compiler/nir/nir_range_analysis.c | 12 +++++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 704e989705c..967c7fe62bb 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -774,7 +774,7 @@ "description": "nir: disable fp class analysis for 64bit transcendentals", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "5a298f3560629943e9140c74547183da1635352e", "notes": null diff --git a/src/compiler/nir/nir_range_analysis.c b/src/compiler/nir/nir_range_analysis.c index ecfdcbc1ca6..5e4702861ca 100644 --- a/src/compiler/nir/nir_range_analysis.c +++ b/src/compiler/nir/nir_range_analysis.c @@ -1039,7 +1039,11 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 } case nir_op_frcp: - r = frcp_fp_class(handle_sz(alu, src_res[0])); + /* Some backends have terrible precision for fp64, + * so don't try to do anything clever. + */ + if (alu->def.bit_size < 64) + r = frcp_fp_class(handle_sz(alu, src_res[0])); break; case nir_op_mov: @@ -1085,11 +1089,13 @@ process_fp_query(struct analysis_state *state, struct analysis_query *aq, uint32 break; case nir_op_fsqrt: - r = fsqrt_fp_class(src_res[0]); + if (alu->def.bit_size < 64) + r = fsqrt_fp_class(src_res[0]); break; case nir_op_frsq: - r = frcp_fp_class(fsqrt_fp_class(handle_sz(alu, src_res[0]))); + if (alu->def.bit_size < 64) + r = frcp_fp_class(fsqrt_fp_class(handle_sz(alu, src_res[0]))); break; case nir_op_ffloor: {