Mesa (master): aco: lower subdword phis with SGPR operands

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Fri Apr 10 07:29:03 UTC 2020


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

Author: Daniel Schürmann <daniel at schuermann.dev>
Date:   Tue Apr  7 12:16:57 2020 +0100

aco: lower subdword phis with SGPR operands

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

---

 src/amd/compiler/aco_lower_bool_phis.cpp | 26 ++++++++++++++++++++++++++
 1 file changed, 26 insertions(+)

diff --git a/src/amd/compiler/aco_lower_bool_phis.cpp b/src/amd/compiler/aco_lower_bool_phis.cpp
index e5e27d70971..1613e4be94a 100644
--- a/src/amd/compiler/aco_lower_bool_phis.cpp
+++ b/src/amd/compiler/aco_lower_bool_phis.cpp
@@ -189,6 +189,30 @@ void lower_divergent_bool_phi(Program *program, Block *block, aco_ptr<Instructio
    return;
 }
 
+void lower_subdword_phis(Program *program, Block *block, aco_ptr<Instruction>& phi)
+{
+   Builder bld(program);
+   for (unsigned i = 0; i < phi->operands.size(); i++) {
+      if (phi->operands[i].isUndefined())
+         continue;
+      if (phi->operands[i].regClass() == phi->definitions[0].regClass())
+         continue;
+
+      assert(phi->operands[i].isTemp());
+      Block *pred = &program->blocks[block->logical_preds[i]];
+      Temp phi_src = phi->operands[i].getTemp();
+
+      assert(phi_src.regClass().type() == RegType::sgpr);
+      Temp tmp = bld.tmp(RegClass(RegType::vgpr, phi_src.size()));
+      insert_before_logical_end(pred, bld.pseudo(aco_opcode::p_create_vector, Definition(tmp), phi_src).get_ptr());
+      Temp new_phi_src = bld.tmp(phi->definitions[0].regClass());
+      insert_before_logical_end(pred, bld.pseudo(aco_opcode::p_extract_vector, Definition(new_phi_src), tmp, Operand(0u)).get_ptr());
+
+      phi->operands[i].setTemp(new_phi_src);
+   }
+   return;
+}
+
 void lower_bool_phis(Program* program)
 {
    for (Block& block : program->blocks) {
@@ -197,6 +221,8 @@ void lower_bool_phis(Program* program)
             assert(program->wave_size == 64 ? phi->definitions[0].regClass() != s1 : phi->definitions[0].regClass() != s2);
             if (phi->definitions[0].regClass() == program->lane_mask)
                lower_divergent_bool_phi(program, &block, phi);
+            else if (phi->definitions[0].regClass().is_subdword())
+               lower_subdword_phis(program, &block, phi);
          } else if (!is_phi(phi)) {
             break;
          }



More information about the mesa-commit mailing list