From 87f92ebdd5551f936fa633533a0929a9f85e9f48 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: (cherry picked from commit 6de40d17baf403978dd136dbbc36c0167dbf7ef9) --- .pick_status.json | 2 +- src/gallium/drivers/r600/sfn/sfn_peephole.cpp | 19 +++++++++++++++---- 2 files changed, 16 insertions(+), 5 deletions(-) diff --git a/.pick_status.json b/.pick_status.json index 40c9a1a5c3d..67404d8ad51 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -1012,7 +1012,7 @@ "description": "r600/sfn: don't propagate registers into conditional test", "nominated": true, "nomination_type": 1, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": "79ca456b4837b3bc21cf9ef3c03c505c4b4909f6" }, diff --git a/src/gallium/drivers/r600/sfn/sfn_peephole.cpp b/src/gallium/drivers/r600/sfn/sfn_peephole.cpp index 065031287dc..8369b9c6508 100644 --- a/src/gallium/drivers/r600/sfn/sfn_peephole.cpp +++ b/src/gallium/drivers/r600/sfn/sfn_peephole.cpp @@ -212,11 +212,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());