From a61a9cd65dd52b4bccfb33c3fba7b28a84a1a4e1 Mon Sep 17 00:00:00 2001 From: Connor Abbott Date: Thu, 4 Mar 2021 12:21:50 +0100 Subject: [PATCH] ir3: Insert output collects in the main shader We were inserting them in what was NIR's end block with the "end" instruction, which meant that the moves they generated couldn't be scheduled with the rest of the last block as part of post-RA scheduling. Part-of: --- src/freedreno/ir3/ir3_compiler_nir.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/freedreno/ir3/ir3_compiler_nir.c b/src/freedreno/ir3/ir3_compiler_nir.c index 6921d9a95c1..d27a6fceb73 100644 --- a/src/freedreno/ir3/ir3_compiler_nir.c +++ b/src/freedreno/ir3/ir3_compiler_nir.c @@ -3882,6 +3882,15 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler, struct ir3_instruction *outputs[ctx->noutputs / 4]; unsigned outputs_count = 0; + struct ir3_block *old_block = ctx->block; + /* Insert these collect's in the block before the end-block if + * possible, so that any moves they generate can be shuffled around to + * reduce nop's: + */ + if (ctx->block->predecessors_count == 1) + ctx->block = ctx->block->predecessors[0]; + + /* Setup IR level outputs, which are "collects" that gather * the scalar components of outputs. */ @@ -3943,6 +3952,8 @@ ir3_compile_shader_nir(struct ir3_compiler *compiler, } } + ctx->block = old_block; + struct ir3_instruction *end = ir3_instr_create(ctx->block, OPC_END, outputs_count + 1);