Mesa (master): aco/spill: reload spilled exec masks directly to exec

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Apr 13 18:55:19 UTC 2021


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

Author: Daniel Schürmann <daniel at schuermann.dev>
Date:   Mon Feb 22 11:00:22 2021 +0100

aco/spill: reload spilled exec masks directly to exec

This handles the case of
   exec = p_linear_phi %a, %b
where %a or %b might have been spilled.
By directly reloading these variables into the exec mask register,
we can avoid additional CSSA parallelcopies.

Reviewed-by: Rhys Perry <pendingchaos02 at gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/9196>

---

 src/amd/compiler/aco_spill.cpp | 19 +++++++++++++------
 1 file changed, 13 insertions(+), 6 deletions(-)

diff --git a/src/amd/compiler/aco_spill.cpp b/src/amd/compiler/aco_spill.cpp
index 8fcb5520483..e5f53a4cdb9 100644
--- a/src/amd/compiler/aco_spill.cpp
+++ b/src/amd/compiler/aco_spill.cpp
@@ -939,7 +939,7 @@ void add_coupling_code(spill_ctx& ctx, Block* block, unsigned block_idx)
             continue;
          unsigned pred_idx = preds[i];
 
-         /* rename operand */
+         /* if the operand was reloaded, rename */
          if (ctx.spills_exit[pred_idx].find(phi->operands[i].getTemp()) == ctx.spills_exit[pred_idx].end()) {
             std::map<Temp, Temp>::iterator it = ctx.renames[pred_idx].find(phi->operands[i].getTemp());
             if (it != ctx.renames[pred_idx].end())
@@ -961,13 +961,20 @@ void add_coupling_code(spill_ctx& ctx, Block* block, unsigned block_idx)
             idx--;
          } while (phi->opcode == aco_opcode::p_phi && pred.instructions[idx]->opcode != aco_opcode::p_logical_end);
          std::vector<aco_ptr<Instruction>>::iterator it = std::next(pred.instructions.begin(), idx);
-
          aco_ptr<Instruction> reload = do_reload(ctx, tmp, new_name, ctx.spills_exit[pred_idx][tmp]);
-         pred.instructions.insert(it, std::move(reload));
 
-         ctx.spills_exit[pred_idx].erase(tmp);
-         ctx.renames[pred_idx][tmp] = new_name;
-         phi->operands[i].setTemp(new_name);
+         /* reload spilled exec mask directly to exec */
+         if (!phi->definitions[0].isTemp()) {
+            assert(phi->definitions[0].isFixed() && phi->definitions[0].physReg() == exec);
+            reload->definitions[0] = phi->definitions[0];
+            phi->operands[i] = Operand(exec, ctx.program->lane_mask);
+         } else {
+            ctx.spills_exit[pred_idx].erase(tmp);
+            ctx.renames[pred_idx][tmp] = new_name;
+            phi->operands[i].setTemp(new_name);
+         }
+
+         pred.instructions.insert(it, std::move(reload));
       }
    }
 



More information about the mesa-commit mailing list