From 9dfb072ae3d7990e6e7269416feb8a5212e08b25 Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 8 Jan 2024 21:48:30 -0400 Subject: [PATCH] agx: ingest undefs in the backend in prep for doing smarter things with them. stats changes seem to be RA lottery, maybe? total instructions in shared programs: 2277305 -> 2278756 (0.06%) instructions in affected programs: 4003 -> 5454 (36.25%) helped: 0 HURT: 9 Instructions are HURT. total bytes in shared programs: 15000418 -> 15008934 (0.06%) bytes in affected programs: 27072 -> 35588 (31.46%) helped: 0 HURT: 9 Bytes are HURT. total halfregs in shared programs: 519229 -> 519245 (<.01%) halfregs in affected programs: 30 -> 46 (53.33%) helped: 0 HURT: 2 Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_compile.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/asahi/compiler/agx_compile.c b/src/asahi/compiler/agx_compile.c index 33c96a3ce75..95bff0b66b1 100644 --- a/src/asahi/compiler/agx_compile.c +++ b/src/asahi/compiler/agx_compile.c @@ -1990,7 +1990,16 @@ agx_emit_undef(agx_builder *b, nir_undef_instr *instr) * the lowering happens in NIR and this just allows for late lowering passes * to result in undefs. */ - agx_mov_imm_to(b, agx_def_index(&instr->def), 0); + if (instr->def.num_components > 1) { + assert(instr->def.num_components <= 4); + agx_index zero = agx_mov_imm(b, instr->def.bit_size, 0); + + agx_emit_collect_to(b, agx_def_index(&instr->def), + instr->def.num_components, + (agx_index[4]){zero, zero, zero, zero}); + } else { + agx_mov_imm_to(b, agx_def_index(&instr->def), 0); + } } static void @@ -2372,7 +2381,6 @@ agx_optimize_loop_nir(nir_shader *nir) NIR_PASS(progress, nir, nir_opt_constant_folding); NIR_PASS(progress, nir, nir_opt_undef); - NIR_PASS(progress, nir, nir_lower_undef_to_zero); NIR_PASS(progress, nir, nir_opt_shrink_vectors); NIR_PASS(progress, nir, nir_opt_loop_unroll);