From 2b264455b51fdb7fa1ed20ec6b795ea608abc2df Mon Sep 17 00:00:00 2001 From: Georg Lehmann Date: Sat, 28 Jan 2023 20:34:55 +0100 Subject: [PATCH] aco: use s_pack_ll_b32_b16 for constant copies MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Totals from 2 (0.00% of 134913) affected shaders: CodeSize: 28636 -> 28628 (-0.03%) Reviewed-by: Timur Kristóf Part-of: --- src/amd/compiler/aco_lower_to_hw_instr.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/amd/compiler/aco_lower_to_hw_instr.cpp b/src/amd/compiler/aco_lower_to_hw_instr.cpp index 74bc6461754..ac5f95361f4 100644 --- a/src/amd/compiler/aco_lower_to_hw_instr.cpp +++ b/src/amd/compiler/aco_lower_to_hw_instr.cpp @@ -1145,13 +1145,21 @@ copy_constant(lower_context* ctx, Builder& bld, Definition dst, Operand op) else bld.vop1(aco_opcode::v_bfrev_b32, dst, Operand::c32(rev)); return; - } else if (dst.regClass() == s1 && imm != 0) { + } else if (dst.regClass() == s1) { unsigned start = (ffs(imm) - 1) & 0x1f; unsigned size = util_bitcount(imm) & 0x1f; - if ((((1u << size) - 1u) << start) == imm) { + if (BITFIELD_RANGE(start, size) == imm) { bld.sop2(aco_opcode::s_bfm_b32, dst, Operand::c32(size), Operand::c32(start)); return; } + if (ctx->program->gfx_level >= GFX9) { + Operand op_lo = Operand::c32(int32_t(int16_t(imm))); + Operand op_hi = Operand::c32(int32_t(int16_t(imm >> 16))); + if (!op_lo.isLiteral() && !op_hi.isLiteral()) { + bld.sop2(aco_opcode::s_pack_ll_b32_b16, dst, op_lo, op_hi); + return; + } + } } }