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

[wasm-simd] Implement v8x16.swizzle for ia32

Bug: v8:8460
Change-Id: I9ac358eabd508d31034e11f28f583c5acbb0b0e2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1849205Reviewed-by: 's avatarDeepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#64202}
parent 3fdc88de
...@@ -279,6 +279,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase { ...@@ -279,6 +279,7 @@ class V8_EXPORT_PRIVATE TurboAssembler : public TurboAssemblerBase {
AVX_OP3_XO(Packsswb, packsswb) AVX_OP3_XO(Packsswb, packsswb)
AVX_OP3_XO(Packuswb, packuswb) AVX_OP3_XO(Packuswb, packuswb)
AVX_OP3_XO(Paddusb, paddusb)
AVX_OP3_XO(Pcmpeqb, pcmpeqb) AVX_OP3_XO(Pcmpeqb, pcmpeqb)
AVX_OP3_XO(Pcmpeqw, pcmpeqw) AVX_OP3_XO(Pcmpeqw, pcmpeqw)
AVX_OP3_XO(Pcmpeqd, pcmpeqd) AVX_OP3_XO(Pcmpeqd, pcmpeqd)
......
...@@ -3535,6 +3535,19 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction( ...@@ -3535,6 +3535,19 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ vxorps(dst, kScratchDoubleReg, i.InputSimd128Register(2)); __ vxorps(dst, kScratchDoubleReg, i.InputSimd128Register(2));
break; break;
} }
case kIA32S8x16Swizzle: {
DCHECK_EQ(i.OutputSimd128Register(), i.InputSimd128Register(0));
XMMRegister dst = i.OutputSimd128Register();
XMMRegister mask = i.TempSimd128Register(0);
// Out-of-range indices should return 0, add 112 so that any value > 15
// saturates to 128 (top bit set), so pshufb will zero that lane.
__ Move(mask, (uint32_t)0x70707070);
__ Pshufd(mask, mask, 0x0);
__ Paddusb(mask, i.InputSimd128Register(1));
__ Pshufb(dst, mask);
break;
}
case kIA32S8x16Shuffle: { case kIA32S8x16Shuffle: {
XMMRegister dst = i.OutputSimd128Register(); XMMRegister dst = i.OutputSimd128Register();
Operand src0 = i.InputOperand(0); Operand src0 = i.InputOperand(0);
......
...@@ -330,6 +330,7 @@ namespace compiler { ...@@ -330,6 +330,7 @@ namespace compiler {
V(AVXS128Xor) \ V(AVXS128Xor) \
V(SSES128Select) \ V(SSES128Select) \
V(AVXS128Select) \ V(AVXS128Select) \
V(IA32S8x16Swizzle) \
V(IA32S8x16Shuffle) \ V(IA32S8x16Shuffle) \
V(IA32S32x4Swizzle) \ V(IA32S32x4Swizzle) \
V(IA32S32x4Shuffle) \ V(IA32S32x4Shuffle) \
......
...@@ -311,6 +311,7 @@ int InstructionScheduler::GetTargetInstructionFlags( ...@@ -311,6 +311,7 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kAVXS128Xor: case kAVXS128Xor:
case kSSES128Select: case kSSES128Select:
case kAVXS128Select: case kAVXS128Select:
case kIA32S8x16Swizzle:
case kIA32S8x16Shuffle: case kIA32S8x16Shuffle:
case kIA32S32x4Swizzle: case kIA32S32x4Swizzle:
case kIA32S32x4Shuffle: case kIA32S32x4Shuffle:
......
...@@ -2569,6 +2569,14 @@ void InstructionSelector::VisitS8x16Shuffle(Node* node) { ...@@ -2569,6 +2569,14 @@ void InstructionSelector::VisitS8x16Shuffle(Node* node) {
Emit(opcode, 1, &dst, input_count, inputs, temp_count, temps); Emit(opcode, 1, &dst, input_count, inputs, temp_count, temps);
} }
void InstructionSelector::VisitS8x16Swizzle(Node* node) {
IA32OperandGenerator g(this);
InstructionOperand temps[] = {g.TempSimd128Register()};
Emit(kIA32S8x16Swizzle, g.DefineSameAsFirst(node),
g.UseRegister(node->InputAt(0)), g.UseUniqueRegister(node->InputAt(1)),
arraysize(temps), temps);
}
// static // static
MachineOperatorBuilder::Flags MachineOperatorBuilder::Flags
InstructionSelector::SupportedMachineOperatorFlags() { InstructionSelector::SupportedMachineOperatorFlags() {
......
...@@ -2668,7 +2668,9 @@ void InstructionSelector::VisitI64x2MinS(Node* node) { UNIMPLEMENTED(); } ...@@ -2668,7 +2668,9 @@ void InstructionSelector::VisitI64x2MinS(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI64x2MaxS(Node* node) { UNIMPLEMENTED(); } void InstructionSelector::VisitI64x2MaxS(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI64x2MinU(Node* node) { UNIMPLEMENTED(); } void InstructionSelector::VisitI64x2MinU(Node* node) { UNIMPLEMENTED(); }
void InstructionSelector::VisitI64x2MaxU(Node* node) { UNIMPLEMENTED(); } void InstructionSelector::VisitI64x2MaxU(Node* node) { UNIMPLEMENTED(); }
#if !V8_TARGET_ARCH_IA32
void InstructionSelector::VisitS8x16Swizzle(Node* node) { UNIMPLEMENTED(); } void InstructionSelector::VisitS8x16Swizzle(Node* node) { UNIMPLEMENTED(); }
#endif // !V8_TARGET_ARCH_IA32
#endif // !V8_TARGET_ARCH_X64 #endif // !V8_TARGET_ARCH_X64
void InstructionSelector::VisitFinishRegion(Node* node) { EmitIdentity(node); } void InstructionSelector::VisitFinishRegion(Node* node) { EmitIdentity(node); }
......
...@@ -2687,7 +2687,7 @@ WASM_SIMD_TEST(S8x16Concat) { ...@@ -2687,7 +2687,7 @@ WASM_SIMD_TEST(S8x16Concat) {
} }
} }
#ifdef V8_TARGET_ARCH_X64 #if V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32
struct SwizzleTestArgs { struct SwizzleTestArgs {
const Shuffle input; const Shuffle input;
const Shuffle indices; const Shuffle indices;
...@@ -2741,7 +2741,7 @@ WASM_SIMD_TEST(S8x16Swizzle) { ...@@ -2741,7 +2741,7 @@ WASM_SIMD_TEST(S8x16Swizzle) {
} }
} }
} }
#endif // V8_TARGET_ARCH_X64 #endif // V8_TARGET_ARCH_X64 || V8_TARGET_ARCH_IA32
// Combine 3 shuffles a, b, and c by applying both a and b and then applying c // Combine 3 shuffles a, b, and c by applying both a and b and then applying c
// to those two results. // to those two results.
......
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