From bb58ba20758c6e60e7179892ebab084682900acf Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Sat, 29 Nov 2025 10:41:17 +0100 Subject: [PATCH] aco/optimizer: propagate salu fabs Foz-DB Navi48: Totals from 5156 (5.28% of 97637) affected shaders: Instrs: 12713219 -> 12694317 (-0.15%); split: -0.15%, +0.00% CodeSize: 67099236 -> 67037588 (-0.09%); split: -0.13%, +0.04% VGPRs: 352620 -> 352608 (-0.00%) SpillSGPRs: 22032 -> 22031 (-0.00%) Latency: 68288972 -> 68271858 (-0.03%); split: -0.03%, +0.00% InvThroughput: 13639078 -> 13633997 (-0.04%); split: -0.04%, +0.00% VClause: 235194 -> 235186 (-0.00%); split: -0.01%, +0.00% SClause: 249057 -> 249012 (-0.02%); split: -0.03%, +0.01% Copies: 963813 -> 960529 (-0.34%); split: -0.36%, +0.02% Branches: 321041 -> 321039 (-0.00%) PreSGPRs: 303392 -> 303295 (-0.03%); split: -0.03%, +0.00% VALU: 7134563 -> 7134533 (-0.00%); split: -0.00%, +0.00% SALU: 1913802 -> 1899948 (-0.72%); split: -0.72%, +0.00% VOPD: 19914 -> 19885 (-0.15%); split: +0.01%, -0.15% Reviewed-by: Rhys Perry Part-of: --- src/amd/compiler/aco_optimizer.cpp | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/amd/compiler/aco_optimizer.cpp b/src/amd/compiler/aco_optimizer.cpp index b1b8f054658..41293a50c0f 100644 --- a/src/amd/compiler/aco_optimizer.cpp +++ b/src/amd/compiler/aco_optimizer.cpp @@ -2838,6 +2838,30 @@ label_instruction(opt_ctx& ctx, aco_ptr& instr) } break; case aco_opcode::s_and_b32: + for (unsigned i = 0; i < 2; i++) { + if (!instr->operands[!i].isTemp()) + continue; + Temp tmp = instr->operands[!i].getTemp(); + const Operand& op = instr->operands[i]; + uint32_t constant; + if (op.isConstant()) + constant = op.constantValue(); + else if (op.isTemp() && ctx.info[op.tempId()].is_constant()) + constant = ctx.info[op.tempId()].val; + else + continue; + + if (constant == 0x7fffffff) { + if (ctx.info[tmp.id()].is_canonicalized(32)) + ctx.info[instr->definitions[0].tempId()].set_canonicalized(32); + ctx.info[instr->definitions[0].tempId()].set_abs(tmp, 32); + } else if (constant == 0x7fff) { + if (ctx.info[tmp.id()].is_canonicalized(16)) + ctx.info[instr->definitions[0].tempId()].set_canonicalized(16); + ctx.info[instr->definitions[0].tempId()].set_abs(tmp, 16); + } + } + FALLTHROUGH; case aco_opcode::s_and_b64: if (fixed_to_exec(instr->operands[1]) && instr->operands[0].isTemp()) { if (ctx.info[instr->operands[0].tempId()].is_uniform_bool()) {