Skip to content

Commit 461b98f

Browse files
ngzhianCommit Bot
authored andcommitted
[wasm-simd] Implement remaining load_extend for x64
This implements the rest of the load extend instructions: - i32x4.load16x4_s - i32x4.load16x4_u - i64x2.load32x2_s - i64x2.load32x2_u Bug: v8:9886 Change-Id: I4649f77bae5224042a1628d9f0498c050b1e599d Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1903812 Reviewed-by: Michael Starzinger <mstarzinger@chromium.org> Reviewed-by: Bill Budge <bbudge@chromium.org> Commit-Queue: Zhi An Ng <zhin@chromium.org> Cr-Commit-Position: refs/heads/master@{#65017}
1 parent 88a2d01 commit 461b98f

13 files changed

Lines changed: 127 additions & 1 deletion

src/codegen/x64/sse-instr.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,11 @@
118118
V(ptest, 66, 0F, 38, 17) \
119119
V(pmovsxbw, 66, 0F, 38, 20) \
120120
V(pmovsxwd, 66, 0F, 38, 23) \
121+
V(pmovsxdq, 66, 0F, 38, 25) \
121122
V(packusdw, 66, 0F, 38, 2B) \
122123
V(pmovzxbw, 66, 0F, 38, 30) \
123124
V(pmovzxwd, 66, 0F, 38, 33) \
125+
V(pmovzxdq, 66, 0F, 38, 35) \
124126
V(pminsb, 66, 0F, 38, 38) \
125127
V(pminsd, 66, 0F, 38, 39) \
126128
V(pminuw, 66, 0F, 38, 3A) \

src/compiler/backend/x64/code-generator-x64.cc

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3718,15 +3718,41 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
37183718
break;
37193719
}
37203720
case kX64I16x8Load8x8S: {
3721+
CpuFeatureScope sse_scope(tasm(), SSE4_1);
37213722
EmitOOLTrapIfNeeded(zone(), this, opcode, instr, __ pc_offset());
37223723
__ pmovsxbw(i.OutputSimd128Register(), i.MemoryOperand());
37233724
break;
37243725
}
37253726
case kX64I16x8Load8x8U: {
3727+
CpuFeatureScope sse_scope(tasm(), SSE4_1);
37263728
EmitOOLTrapIfNeeded(zone(), this, opcode, instr, __ pc_offset());
37273729
__ pmovzxbw(i.OutputSimd128Register(), i.MemoryOperand());
37283730
break;
37293731
}
3732+
case kX64I32x4Load16x4S: {
3733+
CpuFeatureScope sse_scope(tasm(), SSE4_1);
3734+
EmitOOLTrapIfNeeded(zone(), this, opcode, instr, __ pc_offset());
3735+
__ pmovsxwd(i.OutputSimd128Register(), i.MemoryOperand());
3736+
break;
3737+
}
3738+
case kX64I32x4Load16x4U: {
3739+
CpuFeatureScope sse_scope(tasm(), SSE4_1);
3740+
EmitOOLTrapIfNeeded(zone(), this, opcode, instr, __ pc_offset());
3741+
__ pmovzxwd(i.OutputSimd128Register(), i.MemoryOperand());
3742+
break;
3743+
}
3744+
case kX64I64x2Load32x2S: {
3745+
CpuFeatureScope sse_scope(tasm(), SSE4_1);
3746+
EmitOOLTrapIfNeeded(zone(), this, opcode, instr, __ pc_offset());
3747+
__ pmovsxdq(i.OutputSimd128Register(), i.MemoryOperand());
3748+
break;
3749+
}
3750+
case kX64I64x2Load32x2U: {
3751+
CpuFeatureScope sse_scope(tasm(), SSE4_1);
3752+
EmitOOLTrapIfNeeded(zone(), this, opcode, instr, __ pc_offset());
3753+
__ pmovzxdq(i.OutputSimd128Register(), i.MemoryOperand());
3754+
break;
3755+
}
37303756
case kX64S32x4Swizzle: {
37313757
DCHECK_EQ(2, instr->InputCount());
37323758
ASSEMBLE_SIMD_IMM_INSTR(pshufd, i.OutputSimd128Register(), 0,

src/compiler/backend/x64/instruction-codes-x64.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -316,6 +316,10 @@ namespace compiler {
316316
V(X64S64x2LoadSplat) \
317317
V(X64I16x8Load8x8S) \
318318
V(X64I16x8Load8x8U) \
319+
V(X64I32x4Load16x4S) \
320+
V(X64I32x4Load16x4U) \
321+
V(X64I64x2Load32x2S) \
322+
V(X64I64x2Load32x2U) \
319323
V(X64S32x4Swizzle) \
320324
V(X64S32x4Shuffle) \
321325
V(X64S16x8Blend) \

src/compiler/backend/x64/instruction-scheduler-x64.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -367,6 +367,10 @@ int InstructionScheduler::GetTargetInstructionFlags(
367367
case kX64S64x2LoadSplat:
368368
case kX64I16x8Load8x8S:
369369
case kX64I16x8Load8x8U:
370+
case kX64I32x4Load16x4S:
371+
case kX64I32x4Load16x4U:
372+
case kX64I64x2Load32x2S:
373+
case kX64I64x2Load32x2U:
370374
return instr->HasOutput() ? kIsLoadOperation : kHasSideEffect;
371375

372376
case kX64Peek:

src/compiler/backend/x64/instruction-selector-x64.cc

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,18 @@ void InstructionSelector::VisitLoadTransform(Node* node) {
348348
case LoadTransformation::kI16x8Load8x8U:
349349
opcode = kX64I16x8Load8x8U;
350350
break;
351+
case LoadTransformation::kI32x4Load16x4S:
352+
opcode = kX64I32x4Load16x4S;
353+
break;
354+
case LoadTransformation::kI32x4Load16x4U:
355+
opcode = kX64I32x4Load16x4U;
356+
break;
357+
case LoadTransformation::kI64x2Load32x2S:
358+
opcode = kX64I64x2Load32x2S;
359+
break;
360+
case LoadTransformation::kI64x2Load32x2U:
361+
opcode = kX64I64x2Load32x2U;
362+
break;
351363
default:
352364
UNREACHABLE();
353365
}

src/compiler/machine-operator.cc

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,14 @@ std::ostream& operator<<(std::ostream& os, LoadTransformation rep) {
6262
return os << "kI16x8Load8x8S";
6363
case LoadTransformation::kI16x8Load8x8U:
6464
return os << "kI16x8Load8x8U";
65+
case LoadTransformation::kI32x4Load16x4S:
66+
return os << "kI32x4Load16x4S";
67+
case LoadTransformation::kI32x4Load16x4U:
68+
return os << "kI32x4Load16x4U";
69+
case LoadTransformation::kI64x2Load32x2S:
70+
return os << "kI64x2Load32x2S";
71+
case LoadTransformation::kI64x2Load32x2U:
72+
return os << "kI64x2Load32x2U";
6573
}
6674
UNREACHABLE();
6775
}
@@ -523,7 +531,11 @@ MachineType AtomicOpType(Operator const* op) {
523531
V(S32x4LoadSplat) \
524532
V(S64x2LoadSplat) \
525533
V(I16x8Load8x8S) \
526-
V(I16x8Load8x8U)
534+
V(I16x8Load8x8U) \
535+
V(I32x4Load16x4S) \
536+
V(I32x4Load16x4U) \
537+
V(I64x2Load32x2S) \
538+
V(I64x2Load32x2U)
527539

528540
#define ATOMIC_U32_TYPE_LIST(V) \
529541
V(Uint8) \

src/compiler/machine-operator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ enum class LoadTransformation {
6767
kS64x2LoadSplat,
6868
kI16x8Load8x8S,
6969
kI16x8Load8x8U,
70+
kI32x4Load16x4S,
71+
kI32x4Load16x4U,
72+
kI64x2Load32x2S,
73+
kI64x2Load32x2U,
7074
};
7175

7276
size_t hash_value(LoadTransformation);

src/compiler/wasm-compiler.cc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3703,6 +3703,14 @@ LoadTransformation GetLoadTransformation(
37033703
return LoadTransformation::kI16x8Load8x8S;
37043704
} else if (memtype == MachineType::Uint8()) {
37053705
return LoadTransformation::kI16x8Load8x8U;
3706+
} else if (memtype == MachineType::Int16()) {
3707+
return LoadTransformation::kI32x4Load16x4S;
3708+
} else if (memtype == MachineType::Uint16()) {
3709+
return LoadTransformation::kI32x4Load16x4U;
3710+
} else if (memtype == MachineType::Int32()) {
3711+
return LoadTransformation::kI64x2Load32x2S;
3712+
} else if (memtype == MachineType::Uint32()) {
3713+
return LoadTransformation::kI64x2Load32x2U;
37063714
}
37073715
break;
37083716
}

src/wasm/function-body-decoder-impl.h

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2732,6 +2732,22 @@ class WasmFullDecoder : public WasmDecoder<validate> {
27322732
len = DecodeLoadTransformMem(LoadType::kI32Load8U,
27332733
LoadTransformationKind::kExtend);
27342734
break;
2735+
case kExprI32x4Load16x4S:
2736+
len = DecodeLoadTransformMem(LoadType::kI32Load16S,
2737+
LoadTransformationKind::kExtend);
2738+
break;
2739+
case kExprI32x4Load16x4U:
2740+
len = DecodeLoadTransformMem(LoadType::kI32Load16U,
2741+
LoadTransformationKind::kExtend);
2742+
break;
2743+
case kExprI64x2Load32x2S:
2744+
len = DecodeLoadTransformMem(LoadType::kI64Load32S,
2745+
LoadTransformationKind::kExtend);
2746+
break;
2747+
case kExprI64x2Load32x2U:
2748+
len = DecodeLoadTransformMem(LoadType::kI64Load32U,
2749+
LoadTransformationKind::kExtend);
2750+
break;
27352751
default: {
27362752
FunctionSig* sig = WasmOpcodes::Signature(opcode);
27372753
if (!VALIDATE(sig != nullptr)) {

src/wasm/wasm-opcodes.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,10 @@ const char* WasmOpcodes::OpcodeName(WasmOpcode opcode) {
329329
CASE_S64x2_OP(LoadSplat, "load_splat")
330330
CASE_I16x8_OP(Load8x8S, "load8x8_s")
331331
CASE_I16x8_OP(Load8x8U, "load8x8_u")
332+
CASE_I32x4_OP(Load16x4S, "load16x4_s")
333+
CASE_I32x4_OP(Load16x4U, "load16x4_u")
334+
CASE_I64x2_OP(Load32x2S, "load32x2_s")
335+
CASE_I64x2_OP(Load32x2U, "load32x2_u")
332336

333337
// Atomic operations.
334338
CASE_OP(AtomicNotify, "atomic.notify")

0 commit comments

Comments
 (0)