r600/sfn: pre-evaluate allowed dest mask in Alu instructions
authorGert Wollny <gert.wollny@collabora.com>
Thu, 22 Dec 2022 12:21:03 +0000 (13:21 +0100)
committerMarge Bot <emma+marge@anholt.net>
Mon, 2 Jan 2023 14:31:35 +0000 (14:31 +0000)
Signed-off-by: Gert Wollny <gert.wollny@collabora.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20451>

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

index d5e5001..9e6197d 100644 (file)
@@ -68,6 +68,17 @@ AluInstr::AluInstr(EAluOp opcode,
       ASSERT_OR_THROW(dest, "Write flag is set, but no destination register is given");
 
    update_uses();
+
+   if (dest && slots > 1) {
+      switch (m_opcode) {
+      case op2_dot: m_allowed_desk_mask = (1 << (4 - slots)) - 1; break;
+      default:
+         if (has_alu_flag(alu_is_cayman_trans)) {
+            m_allowed_desk_mask = (1 << slots) - 1;
+         }
+      }
+   }
+   assert(!dest || (m_allowed_desk_mask & (1 << dest->chan())));
 }
 
 AluInstr::AluInstr(EAluOp opcode):
@@ -493,20 +504,6 @@ uint8_t AluInstr::allowed_src_chan_mask() const
    return mask;
 }
 
-uint8_t
-AluInstr::allowed_dest_chan_mask() const
-{
-   if (alu_slots() != 1) {
-      if (has_alu_flag(alu_is_cayman_trans))
-         return (1 << alu_slots()) - 1;
-
-      if (m_opcode == op2_dot_ieee) {
-         return (1 << (4 - alu_slots())) - 1;
-      }
-   }
-   return 0xf;
-}
-
 bool
 AluInstr::replace_dest(PRegister new_dest, AluInstr *move_instr)
 {
index dc6a223..8f9f8bf 100644 (file)
@@ -180,7 +180,7 @@ public:
    AluInstr *as_alu() override { return this; }
 
    uint8_t allowed_src_chan_mask() const override;
-   uint8_t allowed_dest_chan_mask() const;
+   uint8_t allowed_dest_chan_mask() const {return m_allowed_desk_mask;}
 
 private:
    friend class AluGroup;
@@ -216,6 +216,7 @@ private:
    int m_priority{0};
    std::set<PRegister, std::less<PRegister>, Allocator<PRegister>> m_extra_dependencies;
    AluGroup *m_parent_group{nullptr};
+   unsigned m_allowed_desk_mask{0xf};
 };
 
 class AluInstrVisitor : public InstrVisitor {