From: Connor Abbott Date: Fri, 15 Nov 2019 12:51:27 +0000 (+0100) Subject: aco: Split vector arguments at the beginning X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=a7f1c63442c26d329f637b96b31f0649468fe673;p=mesa.git aco: Split vector arguments at the beginning Due to how LLVM works we have to make some of the FS inputs become vectors, and therefore have to split them early so that they don't take up extra register pressure due to how RA currently works. Reviewed-by: Daniel Schürmann --- diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp index 23629ffe22b..3b5bf0cc763 100644 --- a/src/amd/compiler/aco_instruction_selection.cpp +++ b/src/amd/compiler/aco_instruction_selection.cpp @@ -7634,6 +7634,19 @@ static void emit_streamout(isel_context *ctx, unsigned stream) } /* end namespace */ +void split_arguments(isel_context *ctx, Pseudo_instruction *startpgm) +{ + /* Split all arguments except for the first (ring_offsets) and the last + * (exec) so that the dead channels don't stay live throughout the program. + */ + for (unsigned i = 1; i < startpgm->definitions.size() - 1; i++) { + if (startpgm->definitions[i].regClass().size() > 1) { + emit_split_vector(ctx, startpgm->definitions[i].getTemp(), + startpgm->definitions[i].regClass().size()); + } + } +} + void handle_bc_optimize(isel_context *ctx) { /* needed when SPI_PS_IN_CONTROL.BC_OPTIMIZE_DISABLE is set to 0 */ @@ -7732,8 +7745,10 @@ void select_program(Program *program, setup_fp_mode(&ctx, nir); if (!i) { - add_startpgm(&ctx); /* needs to be after init_context() for FS */ + /* needs to be after init_context() for FS */ + Pseudo_instruction *startpgm = add_startpgm(&ctx); append_logical_start(ctx.block); + split_arguments(&ctx, startpgm); } if_context ic; diff --git a/src/amd/compiler/aco_instruction_selection_setup.cpp b/src/amd/compiler/aco_instruction_selection_setup.cpp index 1c672e3eb31..5c9c0e925ac 100644 --- a/src/amd/compiler/aco_instruction_selection_setup.cpp +++ b/src/amd/compiler/aco_instruction_selection_setup.cpp @@ -887,7 +887,7 @@ add_fs_arg(isel_context *ctx, arg_info *args, unsigned &vgpr_idx, fs_input input return true; } -void add_startpgm(struct isel_context *ctx) +Pseudo_instruction *add_startpgm(struct isel_context *ctx) { user_sgpr_info user_sgpr_info; bool needs_view_index = needs_view_index_sgpr(ctx); @@ -1038,7 +1038,10 @@ void add_startpgm(struct isel_context *ctx) } } startpgm->definitions[args.count] = Definition{ctx->program->allocateId(), exec, s2}; + Pseudo_instruction *instr = startpgm.get(); ctx->block->instructions.push_back(std::move(startpgm)); + + return instr; } int