From 559a35dcb379e103eecfdb0c23bfc2b8214f8a83 Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Fri, 20 Mar 2026 17:58:23 +0100 Subject: [PATCH] aco: skip fract for sin/cos on gfx6-8 if the src is already in range MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Foz-DB Polaris10: Totals from 1301 (1.86% of 69950) affected shaders: Instrs: 1447217 -> 1445610 (-0.11%); split: -0.11%, +0.00% CodeSize: 7775988 -> 7769588 (-0.08%); split: -0.08%, +0.00% SGPRs: 101712 -> 101776 (+0.06%) SpillSGPRs: 931 -> 927 (-0.43%) Latency: 16119433 -> 16115293 (-0.03%); split: -0.03%, +0.01% InvThroughput: 9605952 -> 9577042 (-0.30%); split: -0.31%, +0.01% VClause: 24591 -> 24593 (+0.01%); split: -0.01%, +0.02% SClause: 29656 -> 29655 (-0.00%) Copies: 133968 -> 134001 (+0.02%); split: -0.01%, +0.03% VALU: 1157855 -> 1156235 (-0.14%) SALU: 124626 -> 124639 (+0.01%); split: -0.00%, +0.01% Reviewed-by: Daniel Schürmann Part-of: --- .../compiler/instruction_selection/aco_select_nir_alu.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/amd/compiler/instruction_selection/aco_select_nir_alu.cpp b/src/amd/compiler/instruction_selection/aco_select_nir_alu.cpp index 1b9994f7593..be0ea1b24ce 100644 --- a/src/amd/compiler/instruction_selection/aco_select_nir_alu.cpp +++ b/src/amd/compiler/instruction_selection/aco_select_nir_alu.cpp @@ -2529,9 +2529,13 @@ visit_alu_instr(isel_context* ctx, nir_alu_instr* instr) } Temp src = get_alu_src(ctx, instr->src[0]); + /* before GFX9, v_sin and v_cos had a valid input domain of [-256, +256] */ - if (ctx->options->gfx_level < GFX9) - src = bld.vop1(fract, bld.def(rc), src); + if (ctx->options->gfx_level < GFX9) { + fp_class_mask fp_class = nir_analyze_fp_class(&ctx->fp_class_ht, instr->src[0].src.ssa); + if (fp_class & (FP_CLASS_ANY_INF | FP_CLASS_LT_NEG_ONE | FP_CLASS_GT_POS_ONE)) + src = bld.vop1(fract, bld.def(rc), src); + } if (dst.regClass() == rc) { bld.vop1(opcode, Definition(dst), src);