aco/optimizer: use new helpers for v_or opts

Foz-DB Navi48:
Totals from 1518 (1.84% of 82419) affected shaders:
Instrs: 6575669 -> 6575601 (-0.00%); split: -0.01%, +0.01%
CodeSize: 35135060 -> 35136020 (+0.00%); split: -0.00%, +0.01%
VGPRs: 99660 -> 99648 (-0.01%)
Latency: 47912874 -> 47910876 (-0.00%); split: -0.01%, +0.00%
InvThroughput: 9913228 -> 9912959 (-0.00%); split: -0.00%, +0.00%
VClause: 151572 -> 151567 (-0.00%); split: -0.01%, +0.00%
SClause: 133112 -> 133109 (-0.00%); split: -0.00%, +0.00%
Copies: 577835 -> 577837 (+0.00%); split: -0.01%, +0.01%
PreSGPRs: 84939 -> 84898 (-0.05%)
PreVGPRs: 75892 -> 75891 (-0.00%)
VALU: 3520300 -> 3520176 (-0.00%); split: -0.00%, +0.00%
SALU: 1026499 -> 1026529 (+0.00%); split: -0.00%, +0.01%
VOPD: 6830 -> 6850 (+0.29%); split: +0.31%, -0.01%

Foz-DB Navi21:
Totals from 1508 (1.83% of 82387) affected shaders:
Instrs: 5053785 -> 5053710 (-0.00%); split: -0.00%, +0.00%
CodeSize: 27603768 -> 27604048 (+0.00%); split: -0.00%, +0.00%
Latency: 44447441 -> 44444474 (-0.01%); split: -0.01%, +0.00%
InvThroughput: 11666771 -> 11666371 (-0.00%); split: -0.00%, +0.00%
SClause: 121429 -> 121435 (+0.00%); split: -0.00%, +0.01%
Copies: 496693 -> 496642 (-0.01%); split: -0.02%, +0.01%
PreSGPRs: 72106 -> 72071 (-0.05%)
PreVGPRs: 69819 -> 69818 (-0.00%)
VALU: 3294641 -> 3294547 (-0.00%); split: -0.00%, +0.00%
SALU: 799012 -> 799014 (+0.00%); split: -0.01%, +0.01%

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/38530>
This commit is contained in:
Georg Lehmann
2024-12-14 17:53:20 +01:00
committed by Marge Bot
parent 88f7e3fff3
commit 3ba783e716
+20 -8
View File
@@ -4583,6 +4583,15 @@ remove_const_cb(opt_ctx& ctx, alu_opt_info& info)
return true;
}
template <unsigned idx, uint32_t constant>
bool
insert_const_cb(opt_ctx& ctx, alu_opt_info& info)
{
assert(idx <= info.operands.size());
info.operands.insert(info.operands.begin() + idx, {Operand::c32(constant)});
return true;
}
template <combine_instr_callback func1, combine_instr_callback func2>
bool
and_cb(opt_ctx& ctx, alu_opt_info& info)
@@ -4703,14 +4712,6 @@ combine_instruction(opt_ctx& ctx, aco_ptr<Instruction>& instr)
}
if (instr->isSDWA()) {
} else if (instr->opcode == aco_opcode::v_or_b32 && ctx.program->gfx_level >= GFX9) {
if (combine_three_valu_op(ctx, instr, aco_opcode::s_or_b32, aco_opcode::v_or3_b32, "012",
1 | 2)) {
} else if (combine_three_valu_op(ctx, instr, aco_opcode::v_or_b32, aco_opcode::v_or3_b32,
"012", 1 | 2)) {
} else if (combine_add_or_then_and_lshl(ctx, instr)) {
} else if (combine_v_andor_not(ctx, instr)) {
}
} else if (instr->opcode == aco_opcode::v_xor_b32 && ctx.program->gfx_level >= GFX10) {
if (combine_three_valu_op(ctx, instr, aco_opcode::v_xor_b32, aco_opcode::v_xor3_b32, "012",
1 | 2)) {
@@ -4955,6 +4956,17 @@ combine_instruction(opt_ctx& ctx, aco_ptr<Instruction>& instr)
add_opt(v_mul_lo_u16, v_pk_mad_u16, 0x3, "120");
else
add_opt(v_mul_lo_u16_e64, v_pk_mad_u16, 0x3, "120");
} else if (info.opcode == aco_opcode::v_or_b32) {
add_opt(v_not_b32, v_bfi_b32, 0x3, "10", insert_const_cb<2, UINT32_MAX>, true);
add_opt(s_not_b32, v_bfi_b32, 0x3, "10", insert_const_cb<2, UINT32_MAX>, true);
if (ctx.program->gfx_level >= GFX9) {
add_opt(v_or_b32, v_or3_b32, 0x3, "012", nullptr, true);
add_opt(s_or_b32, v_or3_b32, 0x3, "012", nullptr, true);
add_opt(v_lshlrev_b32, v_lshl_or_b32, 0x3, "210", nullptr, true);
add_opt(s_lshl_b32, v_lshl_or_b32, 0x3, "120", nullptr, true);
add_opt(v_and_b32, v_and_or_b32, 0x3, "120", nullptr, true);
add_opt(s_and_b32, v_and_or_b32, 0x3, "120", nullptr, true);
}
}
if (match_and_apply_patterns(ctx, info, patterns)) {