aco: make program->needs_vcc independent of VCC hints
authorDaniel Schürmann <daniel@schuermann.dev>
Wed, 16 Mar 2022 09:56:26 +0000 (10:56 +0100)
committerMarge Bot <emma+marge@anholt.net>
Wed, 13 Apr 2022 21:52:43 +0000 (21:52 +0000)
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@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/15408>

src/amd/compiler/aco_live_var_analysis.cpp

index abe8396..58a4023 100644 (file)
@@ -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());