Skip to content

Commit

Permalink
[wasm-simd] Merge all any_true to v128.any_true
Browse files Browse the repository at this point in the history
In WebAssembly/simd#423, all any_true
instructions were removed, and replaced with a single v128.any_true.

This patch removes all but v8x16.any_true, and renames it to
v128.any_true.

Bug: v8:11331
Change-Id: Ie394ec841a1a1c4030c4f589eac2cee8a6a2a1f9
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2639033
Reviewed-by: Georg Neis <neis@chromium.org>
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#72304}
  • Loading branch information
ngzhian authored and Commit Bot committed Jan 25, 2021
1 parent c2795bd commit 9c09c22
Show file tree
Hide file tree
Showing 34 changed files with 63 additions and 165 deletions.
4 changes: 1 addition & 3 deletions src/compiler/backend/arm/code-generator-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3220,9 +3220,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ vrev16(Neon8, i.OutputSimd128Register(), i.InputSimd128Register(0));
break;
}
case kArmV32x4AnyTrue:
case kArmV16x8AnyTrue:
case kArmV8x16AnyTrue: {
case kArmV128AnyTrue: {
const QwNeonRegister& src = i.InputSimd128Register(0);
UseScratchRegisterScope temps(tasm());
DwVfpRegister scratch = temps.AcquireD();
Expand Down
4 changes: 1 addition & 3 deletions src/compiler/backend/arm/instruction-codes-arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,9 @@ namespace compiler {
V(ArmS8x8Reverse) \
V(ArmS8x4Reverse) \
V(ArmS8x2Reverse) \
V(ArmV32x4AnyTrue) \
V(ArmV32x4AllTrue) \
V(ArmV16x8AnyTrue) \
V(ArmV16x8AllTrue) \
V(ArmV8x16AnyTrue) \
V(ArmV128AnyTrue) \
V(ArmV8x16AllTrue) \
V(ArmS128Load8Splat) \
V(ArmS128Load16Splat) \
Expand Down
4 changes: 1 addition & 3 deletions src/compiler/backend/arm/instruction-scheduler-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -307,11 +307,9 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kArmS8x8Reverse:
case kArmS8x4Reverse:
case kArmS8x2Reverse:
case kArmV32x4AnyTrue:
case kArmV32x4AllTrue:
case kArmV16x8AnyTrue:
case kArmV16x8AllTrue:
case kArmV8x16AnyTrue:
case kArmV128AnyTrue:
case kArmV8x16AllTrue:
return kNoOpcodeFlags;

Expand Down
4 changes: 1 addition & 3 deletions src/compiler/backend/arm/instruction-selector-arm.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2596,11 +2596,9 @@ void InstructionSelector::VisitWord32AtomicPairCompareExchange(Node* node) {
V(I8x16Abs, kArmI8x16Abs) \
V(I8x16Popcnt, kArmVcnt) \
V(S128Not, kArmS128Not) \
V(V32x4AnyTrue, kArmV32x4AnyTrue) \
V(V32x4AllTrue, kArmV32x4AllTrue) \
V(V16x8AnyTrue, kArmV16x8AnyTrue) \
V(V16x8AllTrue, kArmV16x8AllTrue) \
V(V8x16AnyTrue, kArmV8x16AnyTrue) \
V(V128AnyTrue, kArmV128AnyTrue) \
V(V8x16AllTrue, kArmV8x16AllTrue)

#define SIMD_SHIFT_OP_LIST(V) \
Expand Down
4 changes: 1 addition & 3 deletions src/compiler/backend/arm64/instruction-selector-arm64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3423,11 +3423,9 @@ void InstructionSelector::VisitInt64AbsWithOverflow(Node* node) {
V(I8x16Abs, kArm64I8x16Abs) \
V(I8x16BitMask, kArm64I8x16BitMask) \
V(S128Not, kArm64S128Not) \
V(V32x4AnyTrue, kArm64V128AnyTrue) \
V(V32x4AllTrue, kArm64V32x4AllTrue) \
V(V16x8AnyTrue, kArm64V128AnyTrue) \
V(V16x8AllTrue, kArm64V16x8AllTrue) \
V(V8x16AnyTrue, kArm64V128AnyTrue) \
V(V128AnyTrue, kArm64V128AnyTrue) \
V(V8x16AllTrue, kArm64V8x16AllTrue)

#define SIMD_SHIFT_OP_LIST(V) \
Expand Down
22 changes: 6 additions & 16 deletions src/compiler/backend/ia32/instruction-selector-ia32.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2336,11 +2336,6 @@ void InstructionSelector::VisitWord32AtomicPairCompareExchange(Node* node) {
V(I8x16BitMask) \
V(S128Not)

#define SIMD_ANYTRUE_LIST(V) \
V(V32x4AnyTrue) \
V(V16x8AnyTrue) \
V(V8x16AnyTrue)

#define SIMD_ALLTRUE_LIST(V) \
V(V32x4AllTrue) \
V(V16x8AllTrue) \
Expand Down Expand Up @@ -2638,17 +2633,12 @@ SIMD_UNOP_LIST(VISIT_SIMD_UNOP)
#undef VISIT_SIMD_UNOP
#undef SIMD_UNOP_LIST

// The implementation of AnyTrue is the same for all shapes.
#define VISIT_SIMD_ANYTRUE(Opcode) \
void InstructionSelector::Visit##Opcode(Node* node) { \
IA32OperandGenerator g(this); \
InstructionOperand temps[] = {g.TempRegister()}; \
Emit(kIA32S128AnyTrue, g.DefineAsRegister(node), \
g.UseRegister(node->InputAt(0)), arraysize(temps), temps); \
}
SIMD_ANYTRUE_LIST(VISIT_SIMD_ANYTRUE)
#undef VISIT_SIMD_ANYTRUE
#undef SIMD_ANYTRUE_LIST
void InstructionSelector::VisitV128AnyTrue(Node* node) {
IA32OperandGenerator g(this);
InstructionOperand temps[] = {g.TempRegister()};
Emit(kIA32S128AnyTrue, g.DefineAsRegister(node),
g.UseRegister(node->InputAt(0)), arraysize(temps), temps);
}

#define VISIT_SIMD_ALLTRUE(Opcode) \
void InstructionSelector::Visit##Opcode(Node* node) { \
Expand Down
8 changes: 2 additions & 6 deletions src/compiler/backend/instruction-selector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2306,16 +2306,12 @@ void InstructionSelector::VisitNode(Node* node) {
return MarkAsSimd128(node), VisitI8x16Swizzle(node);
case IrOpcode::kI8x16Shuffle:
return MarkAsSimd128(node), VisitI8x16Shuffle(node);
case IrOpcode::kV32x4AnyTrue:
return MarkAsWord32(node), VisitV32x4AnyTrue(node);
case IrOpcode::kV32x4AllTrue:
return MarkAsWord32(node), VisitV32x4AllTrue(node);
case IrOpcode::kV16x8AnyTrue:
return MarkAsWord32(node), VisitV16x8AnyTrue(node);
case IrOpcode::kV16x8AllTrue:
return MarkAsWord32(node), VisitV16x8AllTrue(node);
case IrOpcode::kV8x16AnyTrue:
return MarkAsWord32(node), VisitV8x16AnyTrue(node);
case IrOpcode::kV128AnyTrue:
return MarkAsWord32(node), VisitV128AnyTrue(node);
case IrOpcode::kV8x16AllTrue:
return MarkAsWord32(node), VisitV8x16AllTrue(node);
default:
Expand Down
4 changes: 1 addition & 3 deletions src/compiler/backend/x64/code-generator-x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4227,9 +4227,7 @@ CodeGenerator::CodeGenResult CodeGenerator::AssembleArchInstruction(
__ Por(dst, kScratchDoubleReg);
break;
}
case kX64V32x4AnyTrue:
case kX64V16x8AnyTrue:
case kX64V8x16AnyTrue: {
case kX64V128AnyTrue: {
Register dst = i.OutputRegister();
XMMRegister src = i.InputSimd128Register(0);

Expand Down
4 changes: 1 addition & 3 deletions src/compiler/backend/x64/instruction-codes-x64.h
Original file line number Diff line number Diff line change
Expand Up @@ -389,11 +389,9 @@ namespace compiler {
V(X64S8x8Reverse) \
V(X64S8x4Reverse) \
V(X64S8x2Reverse) \
V(X64V32x4AnyTrue) \
V(X64V32x4AllTrue) \
V(X64V16x8AnyTrue) \
V(X64V16x8AllTrue) \
V(X64V8x16AnyTrue) \
V(X64V128AnyTrue) \
V(X64V8x16AllTrue) \
V(X64Prefetch) \
V(X64PrefetchNta) \
Expand Down
4 changes: 1 addition & 3 deletions src/compiler/backend/x64/instruction-scheduler-x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,9 +317,7 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kX64S128Zero:
case kX64S128AllOnes:
case kX64S128AndNot:
case kX64V32x4AnyTrue:
case kX64V32x4AllTrue:
case kX64V16x8AnyTrue:
case kX64V16x8AllTrue:
case kX64I8x16Swizzle:
case kX64I8x16Shuffle:
Expand Down Expand Up @@ -351,7 +349,7 @@ int InstructionScheduler::GetTargetInstructionFlags(
case kX64S8x8Reverse:
case kX64S8x4Reverse:
case kX64S8x2Reverse:
case kX64V8x16AnyTrue:
case kX64V128AnyTrue:
case kX64V8x16AllTrue:
return (instr->addressing_mode() == kMode_None)
? kNoOpcodeFlags
Expand Down
19 changes: 5 additions & 14 deletions src/compiler/backend/x64/instruction-selector-x64.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2977,11 +2977,6 @@ VISIT_ATOMIC_BINOP(Xor)
V(I8x16Shl) \
V(I8x16ShrU)

#define SIMD_ANYTRUE_LIST(V) \
V(V32x4AnyTrue) \
V(V16x8AnyTrue) \
V(V8x16AnyTrue)

#define SIMD_ALLTRUE_LIST(V) \
V(V32x4AllTrue) \
V(V16x8AllTrue) \
Expand Down Expand Up @@ -3172,15 +3167,11 @@ SIMD_BINOP_ONE_TEMP_LIST(VISIT_SIMD_BINOP_ONE_TEMP)
#undef VISIT_SIMD_BINOP_ONE_TEMP
#undef SIMD_BINOP_ONE_TEMP_LIST

#define VISIT_SIMD_ANYTRUE(Opcode) \
void InstructionSelector::Visit##Opcode(Node* node) { \
X64OperandGenerator g(this); \
Emit(kX64##Opcode, g.DefineAsRegister(node), \
g.UseUniqueRegister(node->InputAt(0))); \
}
SIMD_ANYTRUE_LIST(VISIT_SIMD_ANYTRUE)
#undef VISIT_SIMD_ANYTRUE
#undef SIMD_ANYTRUE_LIST
void InstructionSelector::VisitV128AnyTrue(Node* node) {
X64OperandGenerator g(this);
Emit(kX64V128AnyTrue, g.DefineAsRegister(node),
g.UseUniqueRegister(node->InputAt(0)));
}

#define VISIT_SIMD_ALLTRUE(Opcode) \
void InstructionSelector::Visit##Opcode(Node* node) { \
Expand Down
4 changes: 1 addition & 3 deletions src/compiler/machine-operator.cc
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,9 @@ ShiftKind ShiftKindOf(Operator const* op) {
V(S128Not, Operator::kNoProperties, 1, 0, 1) \
V(S128Select, Operator::kNoProperties, 3, 0, 1) \
V(S128AndNot, Operator::kNoProperties, 2, 0, 1) \
V(V32x4AnyTrue, Operator::kNoProperties, 1, 0, 1) \
V(V32x4AllTrue, Operator::kNoProperties, 1, 0, 1) \
V(V16x8AnyTrue, Operator::kNoProperties, 1, 0, 1) \
V(V16x8AllTrue, Operator::kNoProperties, 1, 0, 1) \
V(V8x16AnyTrue, Operator::kNoProperties, 1, 0, 1) \
V(V128AnyTrue, Operator::kNoProperties, 1, 0, 1) \
V(V8x16AllTrue, Operator::kNoProperties, 1, 0, 1) \
V(I8x16Swizzle, Operator::kNoProperties, 2, 0, 1)

Expand Down
4 changes: 1 addition & 3 deletions src/compiler/machine-operator.h
Original file line number Diff line number Diff line change
Expand Up @@ -819,11 +819,9 @@ class V8_EXPORT_PRIVATE MachineOperatorBuilder final
const Operator* I8x16Swizzle();
const Operator* I8x16Shuffle(const uint8_t shuffle[16]);

const Operator* V32x4AnyTrue();
const Operator* V32x4AllTrue();
const Operator* V16x8AnyTrue();
const Operator* V16x8AllTrue();
const Operator* V8x16AnyTrue();
const Operator* V128AnyTrue();
const Operator* V8x16AllTrue();

// load [base + index]
Expand Down
4 changes: 1 addition & 3 deletions src/compiler/opcodes.h
Original file line number Diff line number Diff line change
Expand Up @@ -978,11 +978,9 @@
V(S128AndNot) \
V(I8x16Swizzle) \
V(I8x16Shuffle) \
V(V32x4AnyTrue) \
V(V32x4AllTrue) \
V(V16x8AnyTrue) \
V(V16x8AllTrue) \
V(V8x16AnyTrue) \
V(V128AnyTrue) \
V(V8x16AllTrue) \
V(LoadTransform) \
V(PrefetchTemporal) \
Expand Down
8 changes: 2 additions & 6 deletions src/compiler/simd-scalar-lowering.cc
Original file line number Diff line number Diff line change
Expand Up @@ -166,11 +166,9 @@ void SimdScalarLowering::LowerGraph() {
V(S128Not) \
V(S128AndNot) \
V(S128Select) \
V(V32x4AnyTrue) \
V(V32x4AllTrue) \
V(V16x8AnyTrue) \
V(V16x8AllTrue) \
V(V8x16AnyTrue) \
V(V128AnyTrue) \
V(V8x16AllTrue) \
V(I32x4BitMask) \
V(I32x4ExtMulLowI16x8S) \
Expand Down Expand Up @@ -2220,9 +2218,7 @@ void SimdScalarLowering::LowerNode(Node* node) {
ReplaceNode(node, rep_node, 16);
break;
}
case IrOpcode::kV32x4AnyTrue:
case IrOpcode::kV16x8AnyTrue:
case IrOpcode::kV8x16AnyTrue: {
case IrOpcode::kV128AnyTrue: {
DCHECK_EQ(1, node->InputCount());
// AnyTrue always returns a I32x4, and can work with inputs of any shape,
// but we still need GetReplacementsWithType if input is float.
Expand Down
8 changes: 2 additions & 6 deletions src/compiler/wasm-compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5211,16 +5211,12 @@ Node* WasmGraphBuilder::SimdOp(wasm::WasmOpcode opcode, Node* const* inputs) {
case wasm::kExprS128AndNot:
return graph()->NewNode(mcgraph()->machine()->S128AndNot(), inputs[0],
inputs[1]);
case wasm::kExprV32x4AnyTrue:
return graph()->NewNode(mcgraph()->machine()->V32x4AnyTrue(), inputs[0]);
case wasm::kExprV32x4AllTrue:
return graph()->NewNode(mcgraph()->machine()->V32x4AllTrue(), inputs[0]);
case wasm::kExprV16x8AnyTrue:
return graph()->NewNode(mcgraph()->machine()->V16x8AnyTrue(), inputs[0]);
case wasm::kExprV16x8AllTrue:
return graph()->NewNode(mcgraph()->machine()->V16x8AllTrue(), inputs[0]);
case wasm::kExprV8x16AnyTrue:
return graph()->NewNode(mcgraph()->machine()->V8x16AnyTrue(), inputs[0]);
case wasm::kExprV128AnyTrue:
return graph()->NewNode(mcgraph()->machine()->V128AnyTrue(), inputs[0]);
case wasm::kExprV8x16AllTrue:
return graph()->NewNode(mcgraph()->machine()->V8x16AllTrue(), inputs[0]);
case wasm::kExprI8x16Swizzle:
Expand Down
14 changes: 2 additions & 12 deletions src/wasm/baseline/arm/liftoff-assembler-arm.h
Original file line number Diff line number Diff line change
Expand Up @@ -2964,11 +2964,6 @@ void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst,
liftoff::GetSimd128Register(src));
}

void LiftoffAssembler::emit_v32x4_anytrue(LiftoffRegister dst,
LiftoffRegister src) {
liftoff::EmitAnyTrue(this, dst, src);
}

void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst,
LiftoffRegister src) {
UseScratchRegisterScope temps(this);
Expand Down Expand Up @@ -3141,11 +3136,6 @@ void LiftoffAssembler::emit_i16x8_neg(LiftoffRegister dst,
liftoff::GetSimd128Register(src));
}

void LiftoffAssembler::emit_v16x8_anytrue(LiftoffRegister dst,
LiftoffRegister src) {
liftoff::EmitAnyTrue(this, dst, src);
}

void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst,
LiftoffRegister src) {
UseScratchRegisterScope temps(this);
Expand Down Expand Up @@ -3433,8 +3423,8 @@ void LiftoffAssembler::emit_i8x16_neg(LiftoffRegister dst,
liftoff::GetSimd128Register(src));
}

void LiftoffAssembler::emit_v8x16_anytrue(LiftoffRegister dst,
LiftoffRegister src) {
void LiftoffAssembler::emit_v128_anytrue(LiftoffRegister dst,
LiftoffRegister src) {
liftoff::EmitAnyTrue(this, dst, src);
}

Expand Down
14 changes: 2 additions & 12 deletions src/wasm/baseline/arm64/liftoff-assembler-arm64.h
Original file line number Diff line number Diff line change
Expand Up @@ -2106,11 +2106,6 @@ void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst,
Neg(dst.fp().V4S(), src.fp().V4S());
}

void LiftoffAssembler::emit_v32x4_anytrue(LiftoffRegister dst,
LiftoffRegister src) {
liftoff::EmitAnyTrue(this, dst, src);
}

void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst,
LiftoffRegister src) {
liftoff::EmitAllTrue(this, dst, src, kFormat4S);
Expand Down Expand Up @@ -2277,11 +2272,6 @@ void LiftoffAssembler::emit_i16x8_neg(LiftoffRegister dst,
Neg(dst.fp().V8H(), src.fp().V8H());
}

void LiftoffAssembler::emit_v16x8_anytrue(LiftoffRegister dst,
LiftoffRegister src) {
liftoff::EmitAnyTrue(this, dst, src);
}

void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst,
LiftoffRegister src) {
liftoff::EmitAllTrue(this, dst, src, kFormat8H);
Expand Down Expand Up @@ -2478,8 +2468,8 @@ void LiftoffAssembler::emit_i8x16_neg(LiftoffRegister dst,
Neg(dst.fp().V16B(), src.fp().V16B());
}

void LiftoffAssembler::emit_v8x16_anytrue(LiftoffRegister dst,
LiftoffRegister src) {
void LiftoffAssembler::emit_v128_anytrue(LiftoffRegister dst,
LiftoffRegister src) {
liftoff::EmitAnyTrue(this, dst, src);
}

Expand Down
14 changes: 2 additions & 12 deletions src/wasm/baseline/ia32/liftoff-assembler-ia32.h
Original file line number Diff line number Diff line change
Expand Up @@ -3197,8 +3197,8 @@ void LiftoffAssembler::emit_i8x16_neg(LiftoffRegister dst,
}
}

void LiftoffAssembler::emit_v8x16_anytrue(LiftoffRegister dst,
LiftoffRegister src) {
void LiftoffAssembler::emit_v128_anytrue(LiftoffRegister dst,
LiftoffRegister src) {
liftoff::EmitAnyTrue(this, dst, src);
}

Expand Down Expand Up @@ -3441,11 +3441,6 @@ void LiftoffAssembler::emit_i16x8_neg(LiftoffRegister dst,
}
}

void LiftoffAssembler::emit_v16x8_anytrue(LiftoffRegister dst,
LiftoffRegister src) {
liftoff::EmitAnyTrue(this, dst, src);
}

void LiftoffAssembler::emit_v16x8_alltrue(LiftoffRegister dst,
LiftoffRegister src) {
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqw>(this, dst, src);
Expand Down Expand Up @@ -3617,11 +3612,6 @@ void LiftoffAssembler::emit_i32x4_neg(LiftoffRegister dst,
}
}

void LiftoffAssembler::emit_v32x4_anytrue(LiftoffRegister dst,
LiftoffRegister src) {
liftoff::EmitAnyTrue(this, dst, src);
}

void LiftoffAssembler::emit_v32x4_alltrue(LiftoffRegister dst,
LiftoffRegister src) {
liftoff::EmitAllTrue<&TurboAssembler::Pcmpeqd>(this, dst, src);
Expand Down
Loading

0 comments on commit 9c09c22

Please sign in to comment.