From 6de40d17baf403978dd136dbbc36c0167dbf7ef9 Mon Sep 17 00:00:00 2001 From: Gert Wollny Date: Wed, 5 Oct 2022 11:23:02 +0200 Subject: [PATCH] r600/sfn: don't propagate registers into conditional test We don't check whether the register is overwritten between the actual conditional test and the test of the used result, so don't try to optimize the evaluation of the conditional. Fixes: 79ca456b4837b3bc21cf9ef3c03c505c4b4909f6 r600/sfn: rewrite NIR backend Signed-off-by: Gert Wollny Part-of: --- src/gallium/drivers/r600/sfn/sfn_peephole.cpp | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/gallium/drivers/r600/sfn/sfn_peephole.cpp b/src/gallium/drivers/r600/sfn/sfn_peephole.cpp index 36d77dffa31..4544ff494c1 100644 --- a/src/gallium/drivers/r600/sfn/sfn_peephole.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_peephole.cpp @@ -219,11 +219,22 @@ void ReplaceIfPredicate::visit(AluInstr *alu) if (new_op == op0_nop) return; - /* Have to figure out how to pass the dependency correctly */ - /*for (auto& s : alu->sources()) { - if (s->as_register() && s->as_register()->addr()) + for (auto& s : alu->sources()) { + auto reg = s->as_register(); + /* Protext against propagating + * + * V = COND(R, X) + * R = SOME_OP + * IF (V) + * + * to + * + * R = SOME_OP + * IF (COND(R, X)) + */ + if (reg && !reg->is_ssa()) return; - }*/ + } m_pred->set_op(new_op); m_pred->set_sources(alu->sources());