Commit 6f521386 authored by Zhi An Ng's avatar Zhi An Ng Committed by Commit Bot

[wasm-simd][liftoff][x64] Implement saturating rounding multiply high

Create a macro-assembler helper function to enable code sharing between
Liftoff and TurboFan.

Bug: v8:10971
Change-Id: I10228b502d959dbde670c38c44992fa7133dab7e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2621859Reviewed-by: 's avatarClemens Backes <clemensb@chromium.org>
Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72058}
parent 9e47dd6a
...@@ -2211,6 +2211,17 @@ void TurboAssembler::I16x8ExtMul(XMMRegister dst, XMMRegister src1, ...@@ -2211,6 +2211,17 @@ void TurboAssembler::I16x8ExtMul(XMMRegister dst, XMMRegister src1,
} }
} }
void TurboAssembler::I16x8Q15MulRSatS(XMMRegister dst, XMMRegister src1,
XMMRegister src2) {
// k = i16x8.splat(0x8000)
Pcmpeqd(kScratchDoubleReg, kScratchDoubleReg);
Psllw(kScratchDoubleReg, byte{15});
Pmulhrsw(dst, src1, src2);
Pcmpeqw(kScratchDoubleReg, dst);
Pxor(dst, kScratchDoubleReg);
}
void TurboAssembler::Abspd(XMMRegister dst) { void TurboAssembler::Abspd(XMMRegister dst) {
Andps(dst, ExternalReferenceAsOperand( Andps(dst, ExternalReferenceAsOperand(
ExternalReference::address_of_double_abs_constant())); ExternalReference::address_of_double_abs_constant()));
......
...@@ -592,6 +592,8 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -592,6 +592,8 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
void I16x8ExtMul(XMMRegister dst, XMMRegister src1, XMMRegister src2, void I16x8ExtMul(XMMRegister dst, XMMRegister src1, XMMRegister src2,
bool low, bool is_signed); bool low, bool is_signed);
void I16x8Q15MulRSatS(XMMRegister dst, XMMRegister src1, XMMRegister src2);
void Abspd(XMMRegister dst); void Abspd(XMMRegister dst);
void Negpd(XMMRegister dst); void Negpd(XMMRegister dst);
......
...@@ -3351,16 +3351,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -3351,16 +3351,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break; break;
} }
case kX64I16x8Q15MulRSatS: { case kX64I16x8Q15MulRSatS: {
XMMRegister dst = i.OutputSimd128Register(); __ I16x8Q15MulRSatS(i.OutputSimd128Register(), i.InputSimd128Register(0),
XMMRegister src0 = i.InputSimd128Register(0); i.InputSimd128Register(1));
XMMRegister src1 = i.InputSimd128Register(1);
// k = i16x8.splat(0x8000)
__ Pcmpeqd(kScratchDoubleReg, kScratchDoubleReg);
__ Psllw(kScratchDoubleReg, byte{15});
__ Pmulhrsw(dst, src0, src1);
__ Pcmpeqw(kScratchDoubleReg, dst);
__ Pxor(dst, kScratchDoubleReg);
break; break;
} }
case kX64I8x16Splat: { case kX64I8x16Splat: {
......
...@@ -3317,6 +3317,12 @@ void LiftoffAssembler::emit_i16x8_extmul_high_i8x16_u(LiftoffRegister dst, ...@@ -3317,6 +3317,12 @@ void LiftoffAssembler::emit_i16x8_extmul_high_i8x16_u(LiftoffRegister dst,
src2.high_fp()); src2.high_fp());
} }
void LiftoffAssembler::emit_i16x8_q15mulr_sat_s(LiftoffRegister dst,
LiftoffRegister src1,
LiftoffRegister src2) {
bailout(kSimd, "i16x8_q15mulr_sat_s");
}
void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst, void LiftoffAssembler::emit_i8x16_shuffle(LiftoffRegister dst,
LiftoffRegister lhs, LiftoffRegister lhs,
LiftoffRegister rhs, LiftoffRegister rhs,
......
...@@ -2904,6 +2904,12 @@ void LiftoffAssembler::emit_i16x8_extmul_high_i8x16_u(LiftoffRegister dst, ...@@ -2904,6 +2904,12 @@ void LiftoffAssembler::emit_i16x8_extmul_high_i8x16_u(LiftoffRegister dst,
Umull2(dst.fp().V8H(), src1.fp().V16B(), src2.fp().V16B()); Umull2(dst.fp().V8H(), src1.fp().V16B(), src2.fp().V16B());
} }
void LiftoffAssembler::emit_i16x8_q15mulr_sat_s(LiftoffRegister dst,
LiftoffRegister src1,
LiftoffRegister src2) {
bailout(kSimd, "i16x8_q15mulr_sat_s");
}
void LiftoffAssembler::emit_i32x4_abs(LiftoffRegister dst, void LiftoffAssembler::emit_i32x4_abs(LiftoffRegister dst,
LiftoffRegister src) { LiftoffRegister src) {
Abs(dst.fp().V4S(), src.fp().V4S()); Abs(dst.fp().V4S(), src.fp().V4S());
......
...@@ -3574,6 +3574,12 @@ void LiftoffAssembler::emit_i16x8_extmul_high_i8x16_u(LiftoffRegister dst, ...@@ -3574,6 +3574,12 @@ void LiftoffAssembler::emit_i16x8_extmul_high_i8x16_u(LiftoffRegister dst,
/*low=*/false, /*is_signed=*/false); /*low=*/false, /*is_signed=*/false);
} }
void LiftoffAssembler::emit_i16x8_q15mulr_sat_s(LiftoffRegister dst,
LiftoffRegister src1,
LiftoffRegister src2) {
bailout(kSimd, "i16x8_q15mulr_sat_s");
}
void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst, void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst,
LiftoffRegister src) { LiftoffRegister src) {
if (dst.fp() == src.fp()) { if (dst.fp() == src.fp()) {
......
...@@ -1036,6 +1036,9 @@ class LiftoffAssembler : public TurboAssembler { ...@@ -1036,6 +1036,9 @@ class LiftoffAssembler : public TurboAssembler {
inline void emit_i16x8_extmul_high_i8x16_u(LiftoffRegister dst, inline void emit_i16x8_extmul_high_i8x16_u(LiftoffRegister dst,
LiftoffRegister src1, LiftoffRegister src1,
LiftoffRegister src2); LiftoffRegister src2);
inline void emit_i16x8_q15mulr_sat_s(LiftoffRegister dst,
LiftoffRegister src1,
LiftoffRegister src2);
inline void emit_i32x4_neg(LiftoffRegister dst, LiftoffRegister src); inline void emit_i32x4_neg(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v32x4_anytrue(LiftoffRegister dst, LiftoffRegister src); inline void emit_v32x4_anytrue(LiftoffRegister dst, LiftoffRegister src);
inline void emit_v32x4_alltrue(LiftoffRegister dst, LiftoffRegister src); inline void emit_v32x4_alltrue(LiftoffRegister dst, LiftoffRegister src);
......
...@@ -2935,6 +2935,9 @@ class LiftoffCompiler { ...@@ -2935,6 +2935,9 @@ class LiftoffCompiler {
case wasm::kExprI16x8ExtMulHighI8x16U: case wasm::kExprI16x8ExtMulHighI8x16U:
return EmitBinOp<kS128, kS128>( return EmitBinOp<kS128, kS128>(
&LiftoffAssembler::emit_i16x8_extmul_high_i8x16_u); &LiftoffAssembler::emit_i16x8_extmul_high_i8x16_u);
case wasm::kExprI16x8Q15MulRSatS:
return EmitBinOp<kS128, kS128>(
&LiftoffAssembler::emit_i16x8_q15mulr_sat_s);
case wasm::kExprI32x4Neg: case wasm::kExprI32x4Neg:
return EmitUnOp<kS128, kS128>(&LiftoffAssembler::emit_i32x4_neg); return EmitUnOp<kS128, kS128>(&LiftoffAssembler::emit_i32x4_neg);
case wasm::kExprV32x4AnyTrue: case wasm::kExprV32x4AnyTrue:
......
...@@ -3175,6 +3175,12 @@ void LiftoffAssembler::emit_i16x8_extmul_high_i8x16_u(LiftoffRegister dst, ...@@ -3175,6 +3175,12 @@ void LiftoffAssembler::emit_i16x8_extmul_high_i8x16_u(LiftoffRegister dst,
/*is_signed=*/false); /*is_signed=*/false);
} }
void LiftoffAssembler::emit_i16x8_q15mulr_sat_s(LiftoffRegister dst,
LiftoffRegister src1,
LiftoffRegister src2) {
I16x8Q15MulRSatS(dst.fp(), src1.fp(), src2.fp());
}
void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst, void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst,
LiftoffRegister src) { LiftoffRegister src) {
if (dst.fp() == src.fp()) { if (dst.fp() == src.fp()) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment