emit_x64_vector: Bugfix for EmitVectorLogicalShiftLeft8: shift_amount can be >= 8

This commit is contained in:
Merry 2021-03-27 21:31:51 +00:00
parent dc37fe6e28
commit 91337788ee

View file

@ -1465,11 +1465,13 @@ void EmitX64::EmitVectorLogicalShiftLeft8(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 == 1) { if (shift_amount == 0) {
// do nothing
} else if (shift_amount >= 8) {
code.pxor(result, result);
} else if (shift_amount == 1) {
code.paddb(result, result); code.paddb(result, result);
} else if (shift_amount > 0) { } else if (code.HasAVX512_Icelake()) {
if (code.HasAVX512_Icelake()) {
// Galois 8x8 identity matrix, bit-shifted by the shift-amount
const u64 shift_matrix = 0x0102040810204080 >> (shift_amount * 8); const u64 shift_matrix = 0x0102040810204080 >> (shift_amount * 8);
code.vgf2p8affineqb(result, result, code.MConst(xword_b, shift_matrix), 0); code.vgf2p8affineqb(result, result, code.MConst(xword_b, shift_matrix), 0);
} else { } else {
@ -1479,7 +1481,6 @@ void EmitX64::EmitVectorLogicalShiftLeft8(EmitContext& ctx, IR::Inst* inst) {
code.psllw(result, shift_amount); code.psllw(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);
} }