aco: Don't verify branch exec read when eliminating exec writes.
authorTimur Kristóf <timur.kristof@gmail.com>
Sun, 2 Apr 2023 22:03:37 +0000 (00:03 +0200)
committerMarge Bot <emma+marge@anholt.net>
Mon, 3 Apr 2023 14:36:07 +0000 (14:36 +0000)
Verifying that the branch instruction reads exec is not actually
necessary because the pattern that we look for already implies that.

This prepares for the next commit which will remove the exec operand
from branches that have the same target. These branches will no
longer read exec, but they should still get the same optimization.

Reviewed-by: Daniel Schürmann <daniel@schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/21493>

src/amd/compiler/aco_ssa_elimination.cpp

index 39c33cc..a1c3c4a 100644 (file)
@@ -570,7 +570,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_reads_exec = false;
    bool branch_exec_val_found = false;
    int branch_exec_val_idx = -1;
    int branch_exec_copy_idx = -1;
@@ -591,8 +590,6 @@ eliminate_useless_exec_writes_in_block(ssa_elimination_ctx& ctx, Block& block)
       bool writes_exec = instr_writes_exec(instr.get());
 
       logical_end_found |= instr->opcode == aco_opcode::p_logical_end;
-      branch_reads_exec |= i == (int)(block.instructions.size() - 1) && instr->isBranch() &&
-                           instr->operands.size() && instr->operands[0].physReg() == exec;
 
       /* See if we found an unused exec write. */
       if (writes_exec && !exec_write_used) {
@@ -610,8 +607,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 && branch_reads_exec && instr->operands.size() &&
-             !branch_exec_val_found) {
+         if (!logical_end_found && 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.
              */
@@ -649,8 +645,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_reads_exec && branch_exec_tempid &&
-             branch_exec_copy_idx != -1);
+      assert(logical_end_found && branch_exec_tempid && branch_exec_copy_idx != -1);
       try_optimize_branching_sequence(ctx, block, branch_exec_val_idx, branch_exec_copy_idx);
    }