aco: optimize uniform s_not

fossil-db (navi21):
Totals from 1442 (1.81% of 79825) affected shaders:
Instrs: 2224425 -> 2220624 (-0.17%); split: -0.18%, +0.01%
CodeSize: 11778260 -> 11763264 (-0.13%); split: -0.14%, +0.01%
Latency: 13396254 -> 13392346 (-0.03%); split: -0.03%, +0.00%
InvThroughput: 3145007 -> 3144982 (-0.00%); split: -0.00%, +0.00%
SClause: 53037 -> 53035 (-0.00%); split: -0.01%, +0.01%
Copies: 185852 -> 184777 (-0.58%); split: -0.71%, +0.13%
Branches: 60799 -> 60805 (+0.01%)
PreSGPRs: 62940 -> 62954 (+0.02%); split: -0.01%, +0.03%
SALU: 298564 -> 294761 (-1.27%); split: -1.34%, +0.06%

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Georg Lehmann <dadschoorse@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36177>
This commit is contained in:
Rhys Perry
2025-07-15 16:26:05 +01:00
committed by Marge Bot
parent 85b31c9c4d
commit 0bceb07c03
+19 -2
View File
@@ -4299,12 +4299,29 @@ to_uniform_bool_instr(opt_ctx& ctx, aco_ptr<Instruction>& instr)
case aco_opcode::s_or_b64: instr->opcode = aco_opcode::s_or_b32; break;
case aco_opcode::s_xor_b32:
case aco_opcode::s_xor_b64: instr->opcode = aco_opcode::s_absdiff_i32; break;
case aco_opcode::s_not_b32:
case aco_opcode::s_not_b64: {
aco_ptr<Instruction> new_instr{
create_instruction(aco_opcode::s_absdiff_i32, Format::SOP2, 2, 2)};
new_instr->operands[0] = instr->operands[0];
new_instr->operands[1] = Operand::c32(1);
new_instr->definitions[0] = instr->definitions[0];
new_instr->definitions[1] = instr->definitions[1];
new_instr->pass_flags = instr->pass_flags;
instr = std::move(new_instr);
ctx.info[instr->definitions[0].tempId()].parent_instr = instr.get();
ctx.info[instr->definitions[1].tempId()].parent_instr = instr.get();
break;
}
default:
/* Don't transform other instructions. They are very unlikely to appear here. */
return false;
}
for (Operand& op : instr->operands) {
if (!op.isTemp())
continue;
ctx.uses[op.tempId()]--;
if (ctx.info[op.tempId()].is_uniform_bool()) {
@@ -4330,8 +4347,8 @@ to_uniform_bool_instr(opt_ctx& ctx, aco_ptr<Instruction>& instr)
instr->definitions[0].setTemp(Temp(instr->definitions[0].tempId(), s1));
ctx.program->temp_rc[instr->definitions[0].tempId()] = s1;
assert(instr->operands[0].regClass() == s1);
assert(instr->operands[1].regClass() == s1);
assert(!instr->operands[0].isTemp() || instr->operands[0].regClass() == s1);
assert(!instr->operands[1].isTemp() || instr->operands[1].regClass() == s1);
return true;
}