From facbd13df14ecd7662970da59a570814e57bd305 Mon Sep 17 00:00:00 2001 From: Qiang Yu Date: Tue, 25 Jul 2023 11:19:47 +0800 Subject: [PATCH] aco: skip scratch init when no scratch arg provide epilog does not use scratch so has no scratch arg. Reviewed-by: Rhys Perry Signed-off-by: Qiang Yu Part-of: --- .../compiler/aco_instruction_selection.cpp | 38 ++++++++++--------- 1 file changed, 21 insertions(+), 17 deletions(-) diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index 71396488a8b..41c44b3d962 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -10981,26 +10981,30 @@ add_startpgm(struct isel_context* ctx) } } - if (ctx->program->gfx_level < GFX9) { - /* Stash these in the program so that they can be accessed later when - * handling spilling. - */ - if (ctx->args->ring_offsets.used) - ctx->program->private_segment_buffer = get_arg(ctx, ctx->args->ring_offsets); + /* epilog has no scratch */ + if (ctx->args->scratch_offset.used) { + if (ctx->program->gfx_level < GFX9) { + /* Stash these in the program so that they can be accessed later when + * handling spilling. + */ + if (ctx->args->ring_offsets.used) + ctx->program->private_segment_buffer = get_arg(ctx, ctx->args->ring_offsets); - ctx->program->scratch_offset = get_arg(ctx, ctx->args->scratch_offset); - } else if (ctx->program->gfx_level <= GFX10_3 && ctx->program->stage != raytracing_cs) { - /* Manually initialize scratch. For RT stages scratch initialization is done in the prolog. */ - Operand scratch_offset = Operand(get_arg(ctx, ctx->args->scratch_offset)); - scratch_offset.setLateKill(true); + ctx->program->scratch_offset = get_arg(ctx, ctx->args->scratch_offset); + } else if (ctx->program->gfx_level <= GFX10_3 && ctx->program->stage != raytracing_cs) { + /* Manually initialize scratch. For RT stages scratch initialization is done in the prolog. + */ + Operand scratch_offset = Operand(get_arg(ctx, ctx->args->scratch_offset)); + scratch_offset.setLateKill(true); - Operand scratch_addr = ctx->args->ring_offsets.used - ? Operand(get_arg(ctx, ctx->args->ring_offsets)) - : Operand(s2); + Operand scratch_addr = ctx->args->ring_offsets.used + ? Operand(get_arg(ctx, ctx->args->ring_offsets)) + : Operand(s2); - Builder bld(ctx->program, ctx->block); - bld.pseudo(aco_opcode::p_init_scratch, bld.def(s2), bld.def(s1, scc), scratch_addr, - scratch_offset); + Builder bld(ctx->program, ctx->block); + bld.pseudo(aco_opcode::p_init_scratch, bld.def(s2), bld.def(s1, scc), scratch_addr, + scratch_offset); + } } return startpgm;