Mesa (master): aco: Split vector arguments at the beginning

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Nov 25 13:46:46 UTC 2019


Module: Mesa
Branch: master
Commit: a7f1c63442c26d329f637b96b31f0649468fe673
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=a7f1c63442c26d329f637b96b31f0649468fe673

Author: Connor Abbott <cwabbott0 at gmail.com>
Date:   Fri Nov 15 13:51:27 2019 +0100

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 <daniel at schuermann.dev>

---

 src/amd/compiler/aco_instruction_selection.cpp       | 17 ++++++++++++++++-
 src/amd/compiler/aco_instruction_selection_setup.cpp |  5 ++++-
 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




More information about the mesa-commit mailing list