From 6d93139061cca1cb12c21f5a931f2586e7712c20 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Mon, 5 Dec 2022 17:08:31 +0100 Subject: [PATCH] r600/sfn: allow copy propagation to LDS read dest Signed-off-by: Gert Wollny Part-of: --- src/gallium/drivers/r600/sfn/sfn_instr_lds.cpp | 42 ++++++++++++++++++++++++++ src/gallium/drivers/r600/sfn/sfn_instr_lds.h | 2 ++ 2 files changed, 44 insertions(+) diff --git a/src/gallium/drivers/r600/sfn/sfn_instr_lds.cpp b/src/gallium/drivers/r600/sfn/sfn_instr_lds.cpp index be9bda2..508b058 100644 --- a/src/gallium/drivers/r600/sfn/sfn_instr_lds.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_instr_lds.cpp @@ -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, diff --git a/src/gallium/drivers/r600/sfn/sfn_instr_lds.h b/src/gallium/drivers/r600/sfn/sfn_instr_lds.h index f354cab..ccf5d0b 100644 --- a/src/gallium/drivers/r600/sfn/sfn_instr_lds.h +++ b/src/gallium/drivers/r600/sfn/sfn_instr_lds.h @@ -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& 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; -- 2.7.4