Module: Mesa Branch: main Commit: e493aab3c3f93852482405658fed24d0a429d669 URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e493aab3c3f93852482405658fed24d0a429d669
Author: Rhys Perry <[email protected]> Date: Mon Aug 15 17:46:50 2022 +0100 aco: fix consecutive exec writes when finding exec_copy instruction This can happen with transitions to exact: s2: %0:exec = p_parallelcopy %622:s[0-1] s2: %625:s[0-1], s1: %624:scc, s2: %0:exec = s_and_saveexec_b64 %141:vcc, %0:exec s2: %626:s[12-13] = p_cbranch_z %0:exec BB2, BB1 Signed-off-by: Rhys Perry <[email protected]> Reviewed-by: Georg Lehmann <[email protected]> Reviewed-by: Timur Kristóf <[email protected]> Fixes: 410eff4d2f3 ("aco: Fix optimizing branching sequence with s_and_saveexec.") Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/18077> --- src/amd/compiler/aco_ssa_elimination.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_ssa_elimination.cpp b/src/amd/compiler/aco_ssa_elimination.cpp index 8a58ad03358..5d6857257bc 100644 --- a/src/amd/compiler/aco_ssa_elimination.cpp +++ b/src/amd/compiler/aco_ssa_elimination.cpp @@ -551,6 +551,7 @@ eliminate_useless_exec_writes_in_block(ssa_elimination_ctx& ctx, Block& block) bool logical_end_found = false; bool branch_reads_exec = false; + bool branch_exec_val_found = false; int branch_exec_val_idx = -1; int branch_exec_copy_idx = -1; unsigned branch_exec_tempid = 0; @@ -581,13 +582,15 @@ eliminate_useless_exec_writes_in_block(ssa_elimination_ctx& ctx, Block& block) /* For a newly encountered exec write, clear the used flag. */ if (writes_exec) { - if (!logical_end_found && branch_reads_exec && instr->operands.size()) { + if (!logical_end_found && branch_reads_exec && instr->operands.size() && + !branch_exec_val_found) { /* We are in a branch that jumps according to exec. * We just found the instruction that copies to exec before the branch. */ assert(branch_exec_copy_idx == -1); branch_exec_copy_idx = i; branch_exec_tempid = instr->operands[0].tempId(); + branch_exec_val_found = true; } else if (branch_exec_val_idx == -1) { /* The current instruction overwrites exec before branch_exec_val_idx was * found, therefore we can't optimize the branching sequence.
