ir3/array_to_ssa: fix updating/removing phis

Fix checking instruction flags instead of dst flags, and updating src
instead of def.

Totals:
MaxWaves: 2381954 -> 2381958 (+0.00%)
Instrs: 49073677 -> 49073417 (-0.00%)
CodeSize: 102537524 -> 102536824 (-0.00%)
NOPs: 8396340 -> 8396432 (+0.00%); split: -0.00%, +0.00%
MOVs: 1450777 -> 1450422 (-0.02%)
Full: 1714304 -> 1714287 (-0.00%)
(ss): 1126433 -> 1126463 (+0.00%); split: -0.00%, +0.00%
(ss)-stall: 4013834 -> 4013854 (+0.00%)
(sy)-stall: 16713036 -> 16713082 (+0.00%)
Cat0: 9252109 -> 9252194 (+0.00%); split: -0.00%, +0.00%
Cat1: 2337941 -> 2337592 (-0.01%)
Cat7: 1636810 -> 1636814 (+0.00%); split: -0.00%, +0.00%

Totals from 5 (0.00% of 164705) affected shaders:
MaxWaves: 42 -> 46 (+9.52%)
Instrs: 9052 -> 8792 (-2.87%)
CodeSize: 16806 -> 16106 (-4.17%)
NOPs: 2369 -> 2461 (+3.88%); split: -0.17%, +4.05%
MOVs: 1140 -> 785 (-31.14%)
Full: 133 -> 116 (-12.78%)
(ss): 206 -> 236 (+14.56%); split: -0.97%, +15.53%
(ss)-stall: 901 -> 921 (+2.22%)
(sy)-stall: 6229 -> 6275 (+0.74%)
Cat0: 2695 -> 2780 (+3.15%); split: -0.22%, +3.38%
Cat1: 1333 -> 984 (-26.18%)
Cat7: 419 -> 423 (+0.95%); split: -0.48%, +1.43%

Signed-off-by: Job Noorman <jnoorman@igalia.com>
Fixes: 3ac743c333 ("ir3: Add pass to lower arrays to SSA")
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/36714>
This commit is contained in:
Job Noorman 2025-08-19 15:30:23 +02:00 committed by Marge Bot
parent 2385fa2098
commit ca15116fa1

View file

@ -169,6 +169,8 @@ remove_trivial_phi(struct ir3_instruction *phi)
static struct ir3_register *
lookup_value(struct ir3_register *reg)
{
if (!reg)
return NULL;
if (reg->instr->opc == OPC_META_PHI)
return reg->instr->data;
return reg;
@ -252,14 +254,14 @@ ir3_array_to_ssa(struct ir3 *ir)
foreach_block (block, &ir->block_list) {
foreach_instr_safe (instr, &block->instr_list) {
if (instr->opc == OPC_META_PHI) {
if (!(instr->flags & IR3_REG_ARRAY))
if (!(instr->dsts[0]->flags & IR3_REG_ARRAY))
continue;
if (instr->data != instr->dsts[0]) {
list_del(&instr->node);
continue;
}
for (unsigned i = 0; i < instr->srcs_count; i++) {
instr->srcs[i] = lookup_value(instr->srcs[i]);
instr->srcs[i]->def = lookup_value(instr->srcs[i]->def);
}
} else {
foreach_dst (reg, instr) {