Mesa (main): aco: Fix how p_elect interacts with optimizations.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Sat Jul 17 23:05:39 UTC 2021


Module: Mesa
Branch: main
Commit: 55d57b828f7669a1fd5e4c6c9cc04370a88d31a2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=55d57b828f7669a1fd5e4c6c9cc04370a88d31a2

Author: Timur Kristóf <timur.kristof at gmail.com>
Date:   Sat Jul 17 23:25:52 2021 +0200

aco: Fix how p_elect interacts with optimizations.

Since p_elect doesn't have any operands, ACO's value numbering and/or
the pre-RA optimizer could currently recognize two p_elect instructions
in two different blocks as the same.

This patch adds exec as an operand to p_elect in order to achieve
correct behavior.

Fixes: e66f54e5c83fd545e1a4062e683b584a35dacc00
Closes: #5080
Signed-off-by: Timur Kristóf <timur.kristof at gmail.com>
Reviewed-by: Daniel Schürmann <daniel at schuermann.dev>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11943>

---

 src/amd/compiler/aco_instruction_selection.cpp | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/amd/compiler/aco_instruction_selection.cpp b/src/amd/compiler/aco_instruction_selection.cpp
index 70bf5e8962f..300356d1f3c 100644
--- a/src/amd/compiler/aco_instruction_selection.cpp
+++ b/src/amd/compiler/aco_instruction_selection.cpp
@@ -8722,7 +8722,11 @@ visit_intrinsic(isel_context* ctx, nir_intrinsic_instr* instr)
       break;
    }
    case nir_intrinsic_elect: {
-      Temp elected = bld.pseudo(aco_opcode::p_elect, bld.def(bld.lm));
+      /* p_elect is lowered in aco_insert_exec_mask.
+       * Use exec as an operand so value numbering and the pre-RA optimizer won't recognize
+       * two p_elect with different exec masks as the same.
+       */
+      Temp elected = bld.pseudo(aco_opcode::p_elect, bld.def(bld.lm), Operand(exec, bld.lm));
       emit_wqm(bld, elected, get_ssa_temp(ctx, &instr->dest.ssa));
       ctx->block->kind |= block_kind_needs_lowering;
       break;



More information about the mesa-commit mailing list