From 756bb29391bc368d38472b825510320ddae6042e Mon Sep 17 00:00:00 2001 From: Rhys Perry Date: Fri, 5 Jun 2020 19:18:32 +0100 Subject: [PATCH] aco: create vgpr constant copies using v_bfrev_b32 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Looks like this worked once but broke at some point. fossil-db (Vega): Totals from 577 (0.42% of 137413) affected shaders: CodeSize: 3822052 -> 3818720 (-0.09%) Signed-off-by: Rhys Perry Reviewed-by: Timur Kristóf Part-of: --- src/amd/compiler/aco_lower_to_hw_instr.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/amd/compiler/aco_lower_to_hw_instr.cpp b/src/amd/compiler/aco_lower_to_hw_instr.cpp index 1046f7f2f90..df4c0e46259 100644 --- a/src/amd/compiler/aco_lower_to_hw_instr.cpp +++ b/src/amd/compiler/aco_lower_to_hw_instr.cpp @@ -984,16 +984,19 @@ void copy_constant(lower_context *ctx, Builder& bld, Definition dst, Operand op) { assert(op.bytes() == dst.bytes()); - if (dst.regClass() == s1 && op.isLiteral()) { + if (dst.bytes() == 4 && op.isLiteral()) { uint32_t imm = op.constantValue(); - if (imm >= 0xffff8000 || imm <= 0x7fff) { + if (dst.regClass() == s1 && (imm >= 0xffff8000 || imm <= 0x7fff)) { bld.sopk(aco_opcode::s_movk_i32, dst, imm & 0xFFFFu); return; } else if (util_bitreverse(imm) <= 64 || util_bitreverse(imm) >= 0xFFFFFFF0) { uint32_t rev = util_bitreverse(imm); - bld.sop1(aco_opcode::s_brev_b32, dst, Operand(rev)); + if (dst.regClass() == s1) + bld.sop1(aco_opcode::s_brev_b32, dst, Operand(rev)); + else + bld.vop1(aco_opcode::v_bfrev_b32, dst, Operand(rev)); return; - } else if (imm != 0) { + } else if (dst.regClass() == s1 && imm != 0) { unsigned start = (ffs(imm) - 1) & 0x1f; unsigned size = util_bitcount(imm) & 0x1f; if ((((1u << size) - 1u) << start) == imm) {