aco: use s_bfm_64 for constant copies

Foz-DB Navi21:
Totals from 1025 (0.76% of 134913) affected shaders:
CodeSize: 1436752 -> 1432412 (-0.30%)

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:10:36 +01:00
committed by Marge Bot
parent bbc5247bf7
commit 9ee9b0859b
@@ -1163,6 +1163,15 @@ copy_constant(lower_context* ctx, Builder& bld, Definition dst, Operand op)
} else if (dst.regClass() == s2) {
/* s_ashr_i64 writes SCC, so we can't use it */
assert(Operand::is_constant_representable(op.constantValue64(), 8, true, false));
uint64_t imm = op.constantValue64();
if (op.isLiteral()) {
unsigned start = (ffsll(imm) - 1) & 0x3f;
unsigned size = util_bitcount64(imm) & 0x3f;
if (BITFIELD64_RANGE(start, size) == imm) {
bld.sop2(aco_opcode::s_bfm_b64, dst, Operand::c32(size), Operand::c32(start));
return;
}
}
bld.sop1(aco_opcode::s_mov_b64, dst, op);
} else if (dst.regClass() == v2) {
if (Operand::is_constant_representable(op.constantValue64(), 8, true, false)) {