aco: Pop branch operands when targets are same in SSA elimination.
authorTimur Kristóf <timur.kristof@gmail.com>
Sun, 2 Apr 2023 22:05:09 +0000 (00:05 +0200)
committerMarge Bot <emma+marge@anholt.net>
Mon, 3 Apr 2023 14:36:07 +0000 (14:36 +0000)
The branch instruction is no longer conditional when the targets are the
same, so the operand is not necessary and can be removed.

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 a1c3c4a..5bd545c 100644 (file)
@@ -270,8 +270,12 @@ try_remove_simple_block(ssa_elimination_ctx& ctx, Block* block)
       assert(false);
    }
 
-   if (branch.target[0] == branch.target[1])
+   if (branch.target[0] == branch.target[1]) {
+      while (branch.operands.size())
+         branch.operands.pop_back();
+
       branch.opcode = aco_opcode::p_branch;
+   }
 
    for (unsigned i = 0; i < pred.linear_succs.size(); i++)
       if (pred.linear_succs[i] == block->index)