From 135f3c35c51437ef421cc39b575e9077b78447fd Mon Sep 17 00:00:00 2001 From: Alyssa Rosenzweig Date: Mon, 31 Jul 2023 16:40:48 -0400 Subject: [PATCH] agx: Optimize logical_end removal We know logical_end instructions are only at the end of the block (validated), so by changing how we iterate the pass goes from O(instructions) to O(blocks) which is strictly better. Signed-off-by: Alyssa Rosenzweig Part-of: --- src/asahi/compiler/agx_pack.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/asahi/compiler/agx_pack.c b/src/asahi/compiler/agx_pack.c index 2f1c3c663f3..e46f238f4e6 100644 --- a/src/asahi/compiler/agx_pack.c +++ b/src/asahi/compiler/agx_pack.c @@ -984,9 +984,13 @@ agx_pack_binary(agx_context *ctx, struct util_dynarray *emission) struct util_dynarray fixups; util_dynarray_init(&fixups, ctx); - agx_foreach_instr_global_safe(ctx, I) { - if (I->op == AGX_OPCODE_LOGICAL_END) - agx_remove_instruction(I); + agx_foreach_block(ctx, block) { + agx_foreach_instr_in_block_rev(block, I) { + if (I->op == AGX_OPCODE_LOGICAL_END) { + agx_remove_instruction(I); + break; + } + } } agx_foreach_block(ctx, block) {