Commit b213a6fd authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[wasm-simd][x64][ia32] Factor i64x2.neg into shared code

Bug: v8:11589
Change-Id: I871ec1aecbac065e80c05309e478d814675c0d44
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2828700
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Cr-Commit-Position: refs/heads/master@{#74052}
parent 39e32ac9
...@@ -251,6 +251,22 @@ void SharedTurboAssembler::I32x4UConvertI16x8High(XMMRegister dst, ...@@ -251,6 +251,22 @@ void SharedTurboAssembler::I32x4UConvertI16x8High(XMMRegister dst,
} }
} }
void SharedTurboAssembler::I64x2Neg(XMMRegister dst, XMMRegister src,
XMMRegister scratch) {
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX);
vpxor(scratch, scratch, scratch);
vpsubq(dst, scratch, src);
} else {
if (dst == src) {
movaps(scratch, src);
std::swap(src, scratch);
}
pxor(dst, dst);
psubq(dst, src);
}
}
void SharedTurboAssembler::I64x2Abs(XMMRegister dst, XMMRegister src, void SharedTurboAssembler::I64x2Abs(XMMRegister dst, XMMRegister src,
XMMRegister scratch) { XMMRegister scratch) {
if (CpuFeatures::IsSupported(AVX)) { if (CpuFeatures::IsSupported(AVX)) {
......
...@@ -288,6 +288,7 @@ class V8_EXPORT_PRIVATE SharedTurboAssembler : public TurboAssemblerBase { ...@@ -288,6 +288,7 @@ class V8_EXPORT_PRIVATE SharedTurboAssembler : public TurboAssemblerBase {
void I32x4SConvertI16x8High(XMMRegister dst, XMMRegister src); void I32x4SConvertI16x8High(XMMRegister dst, XMMRegister src);
void I32x4UConvertI16x8High(XMMRegister dst, XMMRegister src, void I32x4UConvertI16x8High(XMMRegister dst, XMMRegister src,
XMMRegister scratch); XMMRegister scratch);
void I64x2Neg(XMMRegister dst, XMMRegister src, XMMRegister scratch);
void I64x2Abs(XMMRegister dst, XMMRegister src, XMMRegister scratch); void I64x2Abs(XMMRegister dst, XMMRegister src, XMMRegister scratch);
void I64x2GtS(XMMRegister dst, XMMRegister src0, XMMRegister src1, void I64x2GtS(XMMRegister dst, XMMRegister src0, XMMRegister src1,
XMMRegister scratch); XMMRegister scratch);
......
...@@ -2132,10 +2132,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -2132,10 +2132,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break; break;
} }
case kIA32I64x2Neg: { case kIA32I64x2Neg: {
XMMRegister dst = i.OutputSimd128Register(); __ I64x2Neg(i.OutputSimd128Register(), i.InputSimd128Register(0),
Operand src = i.InputOperand(0); kScratchDoubleReg);
__ Pxor(dst, dst);
__ Psubq(dst, src);
break; break;
} }
case kIA32I64x2Shl: { case kIA32I64x2Shl: {
......
...@@ -2408,7 +2408,10 @@ void InstructionSelector::VisitI64x2ReplaceLaneI32Pair(Node* node) { ...@@ -2408,7 +2408,10 @@ void InstructionSelector::VisitI64x2ReplaceLaneI32Pair(Node* node) {
void InstructionSelector::VisitI64x2Neg(Node* node) { void InstructionSelector::VisitI64x2Neg(Node* node) {
IA32OperandGenerator g(this); IA32OperandGenerator g(this);
InstructionOperand operand0 = g.UseUnique(node->InputAt(0)); // If AVX unsupported, make sure dst != src to avoid a move.
InstructionOperand operand0 = IsSupported(AVX)
? g.UseRegister(node->InputAt(0))
: g.UseUnique(node->InputAt(0));
Emit(kIA32I64x2Neg, g.DefineAsRegister(node), operand0); Emit(kIA32I64x2Neg, g.DefineAsRegister(node), operand0);
} }
......
...@@ -2773,14 +2773,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -2773,14 +2773,8 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
break; break;
} }
case kX64I64x2Neg: { case kX64I64x2Neg: {
XMMRegister dst = i.OutputSimd128Register(); __ I64x2Neg(i.OutputSimd128Register(), i.InputSimd128Register(0),
XMMRegister src = i.InputSimd128Register(0); kScratchDoubleReg);
if (dst == src) {
__ Movdqa(kScratchDoubleReg, src);
src = kScratchDoubleReg;
}
__ Pxor(dst, dst);
__ Psubq(dst, src);
break; break;
} }
case kX64I64x2BitMask: { case kX64I64x2BitMask: {
......
...@@ -2936,7 +2936,6 @@ VISIT_ATOMIC_BINOP(Xor) ...@@ -2936,7 +2936,6 @@ VISIT_ATOMIC_BINOP(Xor)
V(F32x4RecipApprox) \ V(F32x4RecipApprox) \
V(F32x4RecipSqrtApprox) \ V(F32x4RecipSqrtApprox) \
V(F32x4DemoteF64x2Zero) \ V(F32x4DemoteF64x2Zero) \
V(I64x2Neg) \
V(I64x2BitMask) \ V(I64x2BitMask) \
V(I64x2SConvertI32x4Low) \ V(I64x2SConvertI32x4Low) \
V(I64x2SConvertI32x4High) \ V(I64x2SConvertI32x4High) \
...@@ -3202,6 +3201,15 @@ VISIT_SIMD_QFMOP(F32x4Qfma) ...@@ -3202,6 +3201,15 @@ VISIT_SIMD_QFMOP(F32x4Qfma)
VISIT_SIMD_QFMOP(F32x4Qfms) VISIT_SIMD_QFMOP(F32x4Qfms)
#undef VISIT_SIMD_QFMOP #undef VISIT_SIMD_QFMOP
void InstructionSelector::VisitI64x2Neg(Node* node) {
X64OperandGenerator g(this);
// If AVX unsupported, make sure dst != src to avoid a move.
InstructionOperand operand0 = IsSupported(AVX)
? g.UseRegister(node->InputAt(0))
: g.UseUnique(node->InputAt(0));
Emit(kX64I64x2Neg, g.DefineAsRegister(node), operand0);
}
void InstructionSelector::VisitI64x2ShrS(Node* node) { void InstructionSelector::VisitI64x2ShrS(Node* node) {
X64OperandGenerator g(this); X64OperandGenerator g(this);
InstructionOperand temps[] = {g.TempRegister()}; InstructionOperand temps[] = {g.TempRegister()};
......
...@@ -3855,16 +3855,7 @@ void LiftoffAssembler::emit_i32x4_extmul_high_i16x8_u(LiftoffRegister dst, ...@@ -3855,16 +3855,7 @@ void LiftoffAssembler::emit_i32x4_extmul_high_i16x8_u(LiftoffRegister dst,
void LiftoffAssembler::emit_i64x2_neg(LiftoffRegister dst, void LiftoffAssembler::emit_i64x2_neg(LiftoffRegister dst,
LiftoffRegister src) { LiftoffRegister src) {
DoubleRegister reg = I64x2Neg(dst.fp(), src.fp(), liftoff::kScratchDoubleReg);
dst.fp() == src.fp() ? liftoff::kScratchDoubleReg : dst.fp();
Pxor(reg, reg);
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX);
vpsubq(dst.fp(), reg, src.fp());
} else {
psubq(reg, src.fp());
if (dst.fp() != reg) movaps(dst.fp(), reg);
}
} }
void LiftoffAssembler::emit_i64x2_alltrue(LiftoffRegister dst, void LiftoffAssembler::emit_i64x2_alltrue(LiftoffRegister dst,
......
...@@ -3435,15 +3435,7 @@ void LiftoffAssembler::emit_i32x4_extmul_high_i16x8_u(LiftoffRegister dst, ...@@ -3435,15 +3435,7 @@ void LiftoffAssembler::emit_i32x4_extmul_high_i16x8_u(LiftoffRegister dst,
void LiftoffAssembler::emit_i64x2_neg(LiftoffRegister dst, void LiftoffAssembler::emit_i64x2_neg(LiftoffRegister dst,
LiftoffRegister src) { LiftoffRegister src) {
DoubleRegister reg = dst.fp() == src.fp() ? kScratchDoubleReg : dst.fp(); I64x2Neg(dst.fp(), src.fp(), kScratchDoubleReg);
Pxor(reg, reg);
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope scope(this, AVX);
vpsubq(dst.fp(), reg, src.fp());
} else {
psubq(reg, src.fp());
if (dst.fp() != reg) movaps(dst.fp(), reg);
}
} }
void LiftoffAssembler::emit_i64x2_alltrue(LiftoffRegister dst, void LiftoffAssembler::emit_i64x2_alltrue(LiftoffRegister dst,
......
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