Mesa (main): aco: make program->needs_vcc independent of VCC hints

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Wed Apr 13 22:16:00 UTC 2022


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

Author: Daniel Schürmann <daniel at schuermann.dev>
Date:   Wed Mar 16 10:56:26 2022 +0100

aco: make program->needs_vcc independent of VCC hints

Totals from 5 (0.00% of 135048) affected shaders: (GFX9)
SGPRs: 208 -> 160 (-23.08%)
CodeSize: 2700 -> 2692 (-0.30%)
Instrs: 533 -> 531 (-0.38%)
Latency: 41688 -> 41680 (-0.02%)

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

---

 src/amd/compiler/aco_live_var_analysis.cpp | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/amd/compiler/aco_live_var_analysis.cpp b/src/amd/compiler/aco_live_var_analysis.cpp
index abe839642af..58a4023d787 100644
--- a/src/amd/compiler/aco_live_var_analysis.cpp
+++ b/src/amd/compiler/aco_live_var_analysis.cpp
@@ -88,6 +88,21 @@ struct PhiInfo {
    uint16_t linear_phi_defs = 0;
 };
 
+bool
+instr_needs_vcc(Instruction* instr)
+{
+   if (instr->isVOPC())
+      return true;
+   if (instr->isVOP2() && !instr->isVOP3()) {
+      if (instr->operands.size() == 3 && instr->operands[2].isTemp() &&
+          instr->operands[2].regClass().type() == RegType::sgpr)
+         return true;
+      if (instr->definitions.size() == 2)
+         return true;
+   }
+   return false;
+}
+
 void
 process_live_temps_per_block(Program* program, live& lives, Block* block, unsigned& worklist,
                              std::vector<PhiInfo>& phi_info)
@@ -111,6 +126,7 @@ process_live_temps_per_block(Program* program, live& lives, Block* block, unsign
       if (is_phi(insn))
          break;
 
+      program->needs_vcc |= instr_needs_vcc(insn);
       register_demand[idx] = RegisterDemand(new_demand.vgpr, new_demand.sgpr);
 
       /* KILL */
@@ -118,7 +134,7 @@ process_live_temps_per_block(Program* program, live& lives, Block* block, unsign
          if (!definition.isTemp()) {
             continue;
          }
-         if ((definition.isFixed() || definition.hasHint()) && definition.physReg() == vcc)
+         if (definition.isFixed() && definition.physReg() == vcc)
             program->needs_vcc = true;
 
          const Temp temp = definition.getTemp();
@@ -189,7 +205,7 @@ process_live_temps_per_block(Program* program, live& lives, Block* block, unsign
          continue;
       }
       Definition& definition = insn->definitions[0];
-      if ((definition.isFixed() || definition.hasHint()) && definition.physReg() == vcc)
+      if (definition.isFixed() && definition.physReg() == vcc)
          program->needs_vcc = true;
       const Temp temp = definition.getTemp();
       const size_t n = live.erase(temp.id());



More information about the mesa-commit mailing list