r600/sfn: allow copy propagation to LDS read dest
authorGert Wollny <gert.wollny@collabora.com>
Mon, 5 Dec 2022 16:08:31 +0000 (17:08 +0100)
committerMarge Bot <emma+marge@anholt.net>
Fri, 9 Dec 2022 08:26:30 +0000 (08:26 +0000)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20205>

src/gallium/drivers/r600/sfn/sfn_instr_lds.cpp
src/gallium/drivers/r600/sfn/sfn_instr_lds.h

index be9bda2..508b058 100644 (file)
@@ -227,6 +227,48 @@ LDSReadInstr::from_string(istream& is, ValueFactory& value_factory) -> Pointer
    return new LDSReadInstr(dests, srcs);
 }
 
+bool LDSReadInstr::replace_dest(PRegister new_dest, AluInstr *move_instr)
+{
+   if (new_dest->pin() == pin_array)
+      return false;
+
+   auto old_dest = move_instr->psrc(0);
+
+   bool success = false;
+
+   for (unsigned i = 0; i < m_dest_value.size(); ++i) {
+      auto& dest = m_dest_value[i];
+
+      if (!dest->equal_to(*old_dest))
+         continue;
+
+      if (dest->equal_to(*new_dest))
+         continue;
+
+      if (dest->uses().size() > 1)
+         continue;
+
+      if (dest->pin() == pin_fully)
+         continue;
+
+      if (dest->pin() == pin_group)
+         continue;
+
+      if (dest->pin() == pin_chan && new_dest->chan() != dest->chan())
+         continue;
+
+      if (dest->pin() == pin_chan) {
+         if (new_dest->pin() == pin_group)
+            new_dest->set_pin(pin_chgr);
+         else
+            new_dest->set_pin(pin_chan);
+      }
+      m_dest_value[i] = new_dest;
+      success = true;
+   }
+   return success;
+}
+
 LDSAtomicInstr::LDSAtomicInstr(ESDOp op,
                                PRegister dest,
                                PVirtualValue address,
index f354cab..ccf5d0b 100644 (file)
@@ -46,8 +46,10 @@ public:
 
    void accept(ConstInstrVisitor& visitor) const override;
    void accept(InstrVisitor& visitor) override;
+   bool replace_dest(PRegister new_dest, AluInstr *move_instr) override;
 
    AluInstr *split(std::vector<AluInstr *>& out_block, AluInstr *last_lds_instr);
+
    bool is_equal_to(const LDSReadInstr& lhs) const;
 
    static auto from_string(std::istream& is, ValueFactory& value_factory) -> Pointer;