From a663b85f0366526250d579794c0e98a51bef2452 Mon Sep 17 00:00:00 2001 From: Job Noorman Date: Tue, 19 Aug 2025 15:30:23 +0200 Subject: [PATCH] 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 Fixes: 3ac743c333e ("ir3: Add pass to lower arrays to SSA") Part-of: (cherry picked from commit ca15116fa13a81973f343c63ab4e21bb85c70dd2) --- .pick_status.json | 2 +- src/freedreno/ir3/ir3_array_to_ssa.c | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index f9f65d826a0..cbc35942289 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -754,7 +754,7 @@ "description": "ir3/array_to_ssa: fix updating/removing phis", "nominated": true, "nomination_type": 2, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "3ac743c333e49c6c91e74073eb8ba01cc6762fc6", "notes": null diff --git a/src/freedreno/ir3/ir3_array_to_ssa.c b/src/freedreno/ir3/ir3_array_to_ssa.c index 3a34ae3f7b9..2b3849f8255 100644 --- a/src/freedreno/ir3/ir3_array_to_ssa.c +++ b/src/freedreno/ir3/ir3_array_to_ssa.c @@ -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) {