From f179d999fcecd0cc15a5e3a9d68d17bd9cf0550e Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Tue, 15 Aug 2023 11:23:26 +0100 Subject: [PATCH] aco: fix p_bpermute_gfx6 with input at non-zero byte MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Same as the other bpermute pseudo instructions. Signed-off-by: Rhys Perry Reviewed-by: Samuel Pitoiset Reviewed-by: Daniel Schürmann Reviewed-by: Timur Kristóf Cc: mesa-stable Part-of: (cherry picked from commit 85957dd6e5572dfe424f6fca2ca7a04e95084191) --- .pick_status.json | 2 +- src/amd/compiler/aco_lower_to_hw_instr.cpp | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/.pick_status.json b/.pick_status.json index 5208dd7b037..3285f76b9a5 100644 --- a/.pick_status.json +++ b/.pick_status.json @@ -4054,7 +4054,7 @@ "description": "aco: fix p_bpermute_gfx6 with input at non-zero byte", "nominated": true, "nomination_type": 0, - "resolution": 0, + "resolution": 1, "main_sha": null, "because_sha": null, "notes": null diff --git a/src/amd/compiler/aco_lower_to_hw_instr.cpp b/src/amd/compiler/aco_lower_to_hw_instr.cpp index ea43c3f0cef..efa27872629 100644 --- a/src/amd/compiler/aco_lower_to_hw_instr.cpp +++ b/src/amd/compiler/aco_lower_to_hw_instr.cpp @@ -1109,6 +1109,15 @@ emit_gfx6_bpermute(Program* program, aco_ptr& instr, Builder& bld) /* Restore original EXEC */ bld.sop1(aco_opcode::s_mov_b64, Definition(exec, s2), Operand(temp_exec.physReg(), s2)); } + + /* RA assumes that the result is always in the low part of the register, so we have to shift, + * if it's not there already. + */ + if (input.physReg().byte()) { + unsigned right_shift = input.physReg().byte() * 8; + bld.vop2(aco_opcode::v_lshrrev_b32, dst, Operand::c32(right_shift), + Operand(dst.physReg(), v1)); + } } struct copy_operation {