mirror of
https://github.com/azahar-emu/dynarmic
synced 2025-11-11 01:19:59 +01:00
emit_x64_vector: GNFI implementation of EmitVectorLogicalShiftRight8
Bitshifts of the GFNI identity matrix generates a new matrix that applies lane-wise bitshifts as well. This allows for a fast single-instruction implementation of a byte-lane bitshift.
This commit is contained in:
parent
46f96904db
commit
5cc646ffed
@ -1510,12 +1510,18 @@ void EmitX64::EmitVectorLogicalShiftRight8(EmitContext& ctx, IR::Inst* inst) {
|
|||||||
const u8 shift_amount = args[1].GetImmediateU8();
|
const u8 shift_amount = args[1].GetImmediateU8();
|
||||||
|
|
||||||
if (shift_amount > 0) {
|
if (shift_amount > 0) {
|
||||||
|
if (code.HasAVX512_Icelake()) {
|
||||||
|
// Galois 8x8 identity matrix, bit-shifted by the shift-amount
|
||||||
|
const u64 shift_matrix = 0x0102040810204080 << (shift_amount * 8);
|
||||||
|
code.vgf2p8affineqb(result, result, code.MConst(xword_b, shift_matrix), 0);
|
||||||
|
} else {
|
||||||
const u64 replicand = 0xFEULL >> shift_amount;
|
const u64 replicand = 0xFEULL >> shift_amount;
|
||||||
const u64 mask = Common::Replicate(replicand, Common::BitSize<u8>());
|
const u64 mask = Common::Replicate(replicand, Common::BitSize<u8>());
|
||||||
|
|
||||||
code.psrlw(result, shift_amount);
|
code.psrlw(result, shift_amount);
|
||||||
code.pand(result, code.MConst(xword, mask, mask));
|
code.pand(result, code.MConst(xword, mask, mask));
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
ctx.reg_alloc.DefineValue(inst, result);
|
ctx.reg_alloc.DefineValue(inst, result);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user