emit_x64_vector: Bugfix for EmitVectorLogicalShiftRight8: shift_amount can be >= 8
This commit is contained in:
parent
91337788ee
commit
4d33feb1fa
1 changed files with 12 additions and 11 deletions
|
@ -1524,18 +1524,19 @@ void EmitX64::EmitVectorLogicalShiftRight8(EmitContext& ctx, IR::Inst* inst) {
|
||||||
const Xbyak::Xmm result = ctx.reg_alloc.UseScratchXmm(args[0]);
|
const Xbyak::Xmm result = ctx.reg_alloc.UseScratchXmm(args[0]);
|
||||||
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()) {
|
// Do nothing
|
||||||
// Galois 8x8 identity matrix, bit-shifted by the shift-amount
|
} else if (shift_amount >= 8) {
|
||||||
const u64 shift_matrix = 0x0102040810204080 << (shift_amount * 8);
|
code.pxor(result, result);
|
||||||
code.vgf2p8affineqb(result, result, code.MConst(xword_b, shift_matrix), 0);
|
} else if (code.HasAVX512_Icelake()) {
|
||||||
} else {
|
const u64 shift_matrix = 0x0102040810204080 << (shift_amount * 8);
|
||||||
const u64 replicand = 0xFEULL >> shift_amount;
|
code.vgf2p8affineqb(result, result, code.MConst(xword_b, shift_matrix), 0);
|
||||||
const u64 mask = Common::Replicate(replicand, Common::BitSize<u8>());
|
} else {
|
||||||
|
const u64 replicand = 0xFEULL >> shift_amount;
|
||||||
|
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…
Reference in a new issue