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

Author: Gert Wollny <[email protected]>
Date:   Mon Sep 12 19:00:53 2022 +0200

r600/sfn: Add a free-channel mask when testing whether a register can switch 
channel

This should avoid making 4 slot ops out of 3-slot ops on Cayman

Signed-off-by: Gert Wollny <[email protected]>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18619>

---

 src/gallium/drivers/r600/sfn/sfn_instr_alugroup.cpp | 18 +++++++++++++-----
 1 file changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/gallium/drivers/r600/sfn/sfn_instr_alugroup.cpp 
b/src/gallium/drivers/r600/sfn/sfn_instr_alugroup.cpp
index 379919422bc..e7c7e43b9a7 100644
--- a/src/gallium/drivers/r600/sfn/sfn_instr_alugroup.cpp
+++ b/src/gallium/drivers/r600/sfn/sfn_instr_alugroup.cpp
@@ -137,10 +137,17 @@ public:
    using AluInstrVisitor::visit;
 
    void visit(AluInstr *alu) {
-      yes = (alu->alu_slots() == 1 || alu->has_alu_flag(alu_is_cayman_trans));
+      if (alu->alu_slots() != 1) {
+         if (alu->has_alu_flag(alu_is_cayman_trans)) {
+            free_mask &= (1 << alu->alu_slots()) - 1;
+         } else {
+            yes = false;
+         }
+      }
    }
 
-   bool yes{false};
+   bool yes{true};
+   uint8_t free_mask{0xf};
 
 };
 
@@ -182,18 +189,19 @@ bool AluGroup::add_vec_instructions(AluInstr *instr)
       auto dest = instr->dest();
       if (dest && dest->pin() == pin_free) {
 
+         AluAllowSlotSwitch swich_allowed;
          for (auto u : dest->uses()) {
-            AluAllowSlotSwitch swich_allowed;
             u->accept(swich_allowed);
             if (!swich_allowed.yes)
                return false;
          }
 
          int free_chan = 0;
-         while (m_slots[free_chan] && free_chan < 4)
+         while (free_chan < 4 && (m_slots[free_chan] ||
+                !(swich_allowed.free_mask & (1 << free_chan))))
             free_chan++;
 
-         if (!m_slots[free_chan] && free_chan < 4) {
+         if (free_chan < 4) {
             sfn_log << SfnLog::schedule << "V: Try force channel " << 
free_chan << "\n";
             dest->set_chan(free_chan);
             if (instr->bank_swizzle() != alu_vec_unknown) {

Reply via email to