Commit 820755e8 authored by jing.bao's avatar jing.bao Committed by Commit Bot

[wasm] implement simd lowering for AllTrue/AnyTrue

Change-Id: I7749eae88e4a23d8fe2422e28b8dbcbbfb11f758
Reviewed-on: https://chromium-review.googlesource.com/991733Reviewed-by: 's avatarAseem Garg <aseemgarg@chromium.org>
Commit-Queue: Jing Bao <jing.bao@intel.com>
Cr-Commit-Position: refs/heads/master@{#52585}
parent ebe3e445
......@@ -106,7 +106,13 @@ void SimdScalarLowering::LowerGraph() {
V(S128And) \
V(S128Or) \
V(S128Xor) \
V(S128Not)
V(S128Not) \
V(S1x4AnyTrue) \
V(S1x4AllTrue) \
V(S1x8AnyTrue) \
V(S1x8AllTrue) \
V(S1x16AnyTrue) \
V(S1x16AllTrue)
#define FOREACH_FLOAT32X4_OPCODE(V) \
V(F32x4Splat) \
......@@ -1191,6 +1197,46 @@ void SimdScalarLowering::LowerNode(Node* node) {
ReplaceNode(node, rep_node, 16);
break;
}
case IrOpcode::kS1x4AnyTrue:
case IrOpcode::kS1x4AllTrue:
case IrOpcode::kS1x8AnyTrue:
case IrOpcode::kS1x8AllTrue:
case IrOpcode::kS1x16AnyTrue:
case IrOpcode::kS1x16AllTrue: {
DCHECK_EQ(1, node->InputCount());
SimdType input_rep_type = ReplacementType(node->InputAt(0));
int input_num_lanes = NumLanes(input_rep_type);
Node** rep = GetReplacements(node->InputAt(0));
Node** rep_node = zone()->NewArray<Node*>(num_lanes);
Node* true_node = jsgraph_->Int32Constant(-1);
Node* false_node = jsgraph_->Int32Constant(0);
Node* tmp_result = false_node;
if (node->opcode() == IrOpcode::kS1x4AllTrue ||
node->opcode() == IrOpcode::kS1x8AllTrue ||
node->opcode() == IrOpcode::kS1x16AllTrue) {
tmp_result = true_node;
}
for (int i = 0; i < input_num_lanes; ++i) {
Diamond is_false(
graph(), common(),
graph()->NewNode(machine()->Word32Equal(), rep[i], false_node));
if (node->opcode() == IrOpcode::kS1x4AllTrue ||
node->opcode() == IrOpcode::kS1x8AllTrue ||
node->opcode() == IrOpcode::kS1x16AllTrue) {
tmp_result = is_false.Phi(MachineRepresentation::kWord32, false_node,
tmp_result);
} else {
tmp_result = is_false.Phi(MachineRepresentation::kWord32, tmp_result,
true_node);
}
}
rep_node[0] = tmp_result;
for (int i = 1; i < num_lanes; ++i) {
rep_node[i] = nullptr;
}
ReplaceNode(node, rep_node, num_lanes);
break;
}
default: { DefaultLowering(node); }
}
}
......
......@@ -1902,7 +1902,7 @@ WASM_SIMD_TEST(S8x16Concat) {
// result. Use relational ops on numeric vectors to create the boolean vector
// test inputs. Test inputs with all true, all false, one true, and one false.
#define WASM_SIMD_BOOL_REDUCTION_TEST(format, lanes) \
WASM_SIMD_COMPILED_TEST(ReductionTest##lanes) { \
WASM_SIMD_TEST(ReductionTest##lanes) { \
WasmRunner<int32_t> r(kExecuteTurbofan, lower_simd); \
byte zero = r.AllocateLocal(kWasmS128); \
byte one_one = r.AllocateLocal(kWasmS128); \
......
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