Commit 5e803338 authored by Ng Zhi An's avatar Ng Zhi An Committed by Commit Bot

[wasm-simd][ia32] Implement i64x2.abs

Same code sequence as x64.

Bug: v8:11416
Change-Id: Ibbd4cbf75e10b0ce876d42809d909868fdb86b87
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2686309Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72724}
parent b804a54b
......@@ -2153,6 +2153,24 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ Pinsrd(i.OutputSimd128Register(), i.InputOperand(3), lane * 2 + 1);
break;
}
case kIA32I64x2Abs: {
XMMRegister dst = i.OutputSimd128Register();
XMMRegister src = i.InputSimd128Register(0);
if (CpuFeatures::IsSupported(AVX)) {
CpuFeatureScope avx_scope(tasm(), AVX);
__ vpxor(dst, dst, dst);
__ vpsubq(dst, dst, src);
__ vblendvpd(dst, src, dst, src);
} else {
CpuFeatureScope sse_scope(tasm(), SSE3);
DCHECK_EQ(dst, src);
__ movshdup(kScratchDoubleReg, src);
__ psrad(kScratchDoubleReg, 31);
__ xorps(dst, kScratchDoubleReg);
__ psubq(dst, kScratchDoubleReg);
}
break;
}
case kIA32I64x2Neg: {
XMMRegister dst = i.OutputSimd128Register();
Operand src = i.InputOperand(0);
......
......@@ -140,6 +140,7 @@ namespace compiler {
V(IA32F64x2PromoteLowF32x4) \
V(IA32I64x2SplatI32Pair) \
V(IA32I64x2ReplaceLaneI32Pair) \
V(IA32I64x2Abs) \
V(IA32I64x2Neg) \
V(IA32I64x2Shl) \
V(IA32I64x2ShrS) \
......
......@@ -125,6 +125,7 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kIA32F64x2PromoteLowF32x4:
case kIA32I64x2SplatI32Pair:
case kIA32I64x2ReplaceLaneI32Pair:
case kIA32I64x2Abs:
case kIA32I64x2Neg:
case kIA32I64x2Shl:
case kIA32I64x2ShrS:
......
......@@ -3201,6 +3201,17 @@ void InstructionSelector::VisitI64x2GeS(Node* node) {
}
}
void InstructionSelector::VisitI64x2Abs(Node* node) {
IA32OperandGenerator g(this);
if (CpuFeatures::IsSupported(AVX)) {
Emit(kIA32I64x2Abs, g.DefineAsRegister(node),
g.UseUniqueRegister(node->InputAt(0)));
} else {
Emit(kIA32I64x2Abs, g.DefineSameAsFirst(node),
g.UseRegister(node->InputAt(0)));
}
}
// static
MachineOperatorBuilder::Flags
InstructionSelector::SupportedMachineOperatorFlags() {
......
......@@ -2807,9 +2807,9 @@ void InstructionSelector::VisitI64x2GeS(Node* node) { UNIMPLEMENTED(); }
#endif //! V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_ARM64 && !V8_TARGET_ARCH_IA32
// TODO(v8:11416) Prototyping i64x2.abs.
#if !V8_TARGET_ARCH_X64
#if !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32
void InstructionSelector::VisitI64x2Abs(Node* node) { UNIMPLEMENTED(); }
#endif // !V8_TARGET_ARCH_X64
#endif // !V8_TARGET_ARCH_X64 && !V8_TARGET_ARCH_IA32
void InstructionSelector::VisitFinishRegion(Node* node) { EmitIdentity(node); }
......
......@@ -952,11 +952,11 @@ WASM_SIMD_TEST(I64x2Neg) {
}
// TODO(v8:11416) Prototyping i64x2.abs.
#if V8_TARGET_ARCH_X64
#if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32
WASM_SIMD_TEST_NO_LOWERING(I64x2Abs) {
RunI64x2UnOpTest(execution_tier, lower_simd, kExprI64x2Abs, std::abs);
}
#endif // V8_TARGET_ARCH_X64
#endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32
void RunI64x2ShiftOpTest(TestExecutionTier execution_tier, LowerSimd lower_simd,
WasmOpcode opcode, Int64ShiftOp expected_op) {
......
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