aco: use s_pack_ll_b32_b16 for constant copies

Totals from 2 (0.00% of 134913) affected shaders:
CodeSize: 28636 -> 28628 (-0.03%)

Reviewed-by: Timur Kristóf <timur.kristof@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/20970>
This commit is contained in:
Georg Lehmann 2023-01-28 20:34:55 +01:00 committed by Marge Bot
parent 9ee9b0859b
commit 2b264455b5

View file

@ -1145,13 +1145,21 @@ copy_constant(lower_context* ctx, Builder& bld, Definition dst, Operand op)
else else
bld.vop1(aco_opcode::v_bfrev_b32, dst, Operand::c32(rev)); bld.vop1(aco_opcode::v_bfrev_b32, dst, Operand::c32(rev));
return; return;
} else if (dst.regClass() == s1 && imm != 0) { } else if (dst.regClass() == s1) {
unsigned start = (ffs(imm) - 1) & 0x1f; unsigned start = (ffs(imm) - 1) & 0x1f;
unsigned size = util_bitcount(imm) & 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)); bld.sop2(aco_opcode::s_bfm_b32, dst, Operand::c32(size), Operand::c32(start));
return; 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;
}
}
} }
} }