From 9ca71b52aa5bc2eda1f08149f7780e59858ee27b Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 6 May 2025 16:47:44 +0100 Subject: [PATCH] aco: swap the correct v_mov_b32 if there are two of them Previously, this function tried to swap the instruction which is not v_mov_b32, so that it doesn't introduce any new OPY-only instructions. If both were v_mov_b32, it swapped Y. Since this makes Y opy-only, this can't be done if X is also opy-only. Signed-off-by: Rhys Perry Fixes: 408fa33c0928 ("aco/gfx12: don't use second VALU for VOPD's OPX if there is a WaR") Closes: https://gitlab.freedesktop.org/mesa/mesa/-/issues/13101 Reviewed-by: Georg Lehmann Part-of: --- src/amd/compiler/aco_scheduler_ilp.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/amd/compiler/aco_scheduler_ilp.cpp b/src/amd/compiler/aco_scheduler_ilp.cpp index ee7a6ca5d14..f2d7e2f50af 100644 --- a/src/amd/compiler/aco_scheduler_ilp.cpp +++ b/src/amd/compiler/aco_scheduler_ilp.cpp @@ -808,13 +808,17 @@ create_vopd_instruction(const SchedILPContext& ctx, unsigned idx, unsigned compa if (compat & vopd_need_swap) { assert(x_info.is_commutative || y_info.is_commutative); /* Avoid swapping v_mov_b32 because it will become an OPY-only opcode. */ - if (x_info.op == aco_opcode::v_dual_mov_b32 && !y_info.is_commutative) { + if (x_info.op == aco_opcode::v_dual_mov_b32 && y_info.op == aco_opcode::v_dual_mov_b32) { + swap_x = !x_info.can_be_opx; + swap_y = !swap_x; + } else if (x_info.op == aco_opcode::v_dual_mov_b32 && !y_info.is_commutative) { swap_x = true; x_info.can_be_opx = false; } else { swap_x = x_info.is_commutative && x_info.op != aco_opcode::v_dual_mov_b32; swap_y = y_info.is_commutative && !swap_x; } + y_info.can_be_opx &= !swap_y || y_info.op != aco_opcode::v_dual_mov_b32; } if (!x_info.can_be_opx) {