aco: remove unused p_logical_end check when optimizing branching sequence
authorRhys Perry <pendingchaos02@gmail.com>
Fri, 15 Sep 2023 11:06:48 +0000 (12:06 +0100)
committerMarge Bot <emma+marge@anholt.net>
Mon, 18 Sep 2023 11:19:28 +0000 (11:19 +0000)
I don't see why a p_logical_end is expected or required. It might not be
present in some situations, which causes an assertion failure:
 s2: %19646:s[0-1] = p_reload %19701:v[8], 11
 s2: %0:exec,  s1: %8817:scc = s_andn2_b64 %19646:s[0-1], %0:exec
 s2: %8818:s[20-21] = p_cbranch_z %0:exec BB1116, BB1114

No fossil-db changes (gfx1100).

Signed-off-by: Rhys Perry <pendingchaos02@gmail.com>
Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Cc: mesa-stable
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/25244>

src/amd/compiler/aco_ssa_elimination.cpp

index 043221a..8064414 100644 (file)
@@ -568,7 +568,6 @@ eliminate_useless_exec_writes_in_block(ssa_elimination_ctx& ctx, Block& block)
 
    /* Collect information about the branching sequence. */
 
-   bool logical_end_found = false;
    bool branch_exec_val_found = false;
    int branch_exec_val_idx = -1;
    int branch_exec_copy_idx = -1;
@@ -590,8 +589,6 @@ eliminate_useless_exec_writes_in_block(ssa_elimination_ctx& ctx, Block& block)
          (instr->opcode == aco_opcode::p_logical_end && !ctx.logical_phi_info[block.index].empty());
       bool writes_exec = instr_writes_exec(instr.get());
 
-      logical_end_found |= instr->opcode == aco_opcode::p_logical_end;
-
       /* See if we found an unused exec write. */
       if (writes_exec && !exec_write_used) {
          /* Don't eliminate an instruction that writes registers other than exec and scc.
@@ -609,7 +606,7 @@ 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 && instr->operands.size() && !branch_exec_val_found) {
+         if (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.
              */
@@ -647,7 +644,7 @@ eliminate_useless_exec_writes_in_block(ssa_elimination_ctx& ctx, Block& block)
 
    /* See if we can optimize the instruction that produces the exec mask. */
    if (branch_exec_val_idx != -1) {
-      assert(logical_end_found && branch_exec_tempid && branch_exec_copy_idx != -1);
+      assert(branch_exec_tempid && branch_exec_copy_idx != -1);
       try_optimize_branching_sequence(ctx, block, branch_exec_val_idx, branch_exec_copy_idx);
    }