summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorConnor Abbott <[email protected]>2019-11-15 13:51:27 +0100
committerConnor Abbott <[email protected]>2019-11-25 14:17:51 +0100
commita7f1c63442c26d329f637b96b31f0649468fe673 (patch)
treef900a754a918a5fe29e90a2a3c3ba2d62a1c8215
parentb45c54ff8d21b9e9dcfee7980b1837350be27708 (diff)
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 <[email protected]>
-rw-r--r--src/amd/compiler/aco_instruction_selection.cpp17
-rw-r--r--src/amd/compiler/aco_instruction_selection_setup.cpp5
2 files changed, 20 insertions, 2 deletions
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