Commit 4e6bcd29 authored by Sreten Kovacevic's avatar Sreten Kovacevic Committed by Commit Bot

[simd] Implement conversion simd lowering

Implement lowering for simd operations I32x4ConvertI16x8 and
I16x8ConvertI8x16. Also, remove skip tests from status files that
were overriden when tests were renamed.

TEST=cctest/test-run-wasm-simd/RunWasm_I16x8ConvertI8x16_turbofan

Change-Id: If428f5039a32995c8ee64294c936419173a87aa7
Reviewed-on: https://chromium-review.googlesource.com/1069007Reviewed-by: 's avatarAseem Garg <aseemgarg@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Commit-Queue: Andreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#53343}
parent 3df16820
......@@ -678,6 +678,39 @@ void SimdScalarLowering::LowerConvertFromFloat(Node* node, bool is_signed) {
ReplaceNode(node, rep_node, kNumLanes32);
}
void SimdScalarLowering::LowerConvertFromInt(Node* node,
SimdType input_rep_type,
SimdType output_rep_type,
bool is_signed) {
DCHECK_EQ(1, node->InputCount());
Node** rep = GetReplacementsWithType(node->InputAt(0), input_rep_type);
int32_t shift_val = 0;
if (input_rep_type == SimdType::kInt16x8) {
DCHECK_EQ(output_rep_type, SimdType::kInt32x4);
shift_val = kShift16;
} else {
DCHECK_EQ(output_rep_type, SimdType::kInt16x8);
DCHECK_EQ(input_rep_type, SimdType::kInt8x16);
shift_val = kShift8;
}
int num_lanes = NumLanes(output_rep_type);
Node** rep_node = zone()->NewArray<Node*>(num_lanes);
for (int i = 0; i < num_lanes; ++i) {
rep_node[i] = rep[i];
if (!is_signed) {
rep_node[i] =
graph()->NewNode(machine()->Word32Shr(),
graph()->NewNode(machine()->Word32Shl(), rep_node[i],
mcgraph_->Int32Constant(shift_val)),
mcgraph_->Int32Constant(shift_val));
}
}
ReplaceNode(node, rep_node, num_lanes);
}
void SimdScalarLowering::LowerPack(Node* node, SimdType input_rep_type,
SimdType output_rep_type, bool is_signed) {
DCHECK_EQ(2, node->InputCount());
......@@ -1068,6 +1101,26 @@ void SimdScalarLowering::LowerNode(Node* node) {
LowerConvertFromFloat(node, false);
break;
}
case IrOpcode::kI32x4SConvertI16x8Low:
case IrOpcode::kI32x4SConvertI16x8High: {
LowerConvertFromInt(node, SimdType::kInt16x8, SimdType::kInt32x4, true);
break;
}
case IrOpcode::kI32x4UConvertI16x8Low:
case IrOpcode::kI32x4UConvertI16x8High: {
LowerConvertFromInt(node, SimdType::kInt16x8, SimdType::kInt32x4, false);
break;
}
case IrOpcode::kI16x8SConvertI8x16Low:
case IrOpcode::kI16x8SConvertI8x16High: {
LowerConvertFromInt(node, SimdType::kInt8x16, SimdType::kInt16x8, true);
break;
}
case IrOpcode::kI16x8UConvertI8x16Low:
case IrOpcode::kI16x8UConvertI8x16High: {
LowerConvertFromInt(node, SimdType::kInt8x16, SimdType::kInt16x8, false);
break;
}
case IrOpcode::kI16x8SConvertI32x4: {
LowerPack(node, SimdType::kInt32x4, SimdType::kInt16x8, true);
break;
......
......@@ -91,6 +91,8 @@ class SimdScalarLowering {
void LowerIntMinMax(Node* node, const Operator* op, bool is_max,
SimdType type);
void LowerConvertFromFloat(Node* node, bool is_signed);
void LowerConvertFromInt(Node* node, SimdType input_rep_type,
SimdType output_rep_type, bool is_signed);
void LowerPack(Node* node, SimdType input_rep_type, SimdType output_rep_type,
bool is_signed);
void LowerShiftOp(Node* node, SimdType type);
......
......@@ -346,10 +346,6 @@
['(arch == mipsel or arch == mips64el or arch == mips or arch == mips64) and not simd_mips', {
# Skip tests that fail on MIPS architectures which don't support SIMD,
# because lowering mechanism doesn't work properly
'test-run-wasm-simd/RunWasm_I32x4ConvertI16x8_compiled': [SKIP],
'test-run-wasm-simd/RunWasm_I16x8ConvertI8x16_compiled': [SKIP],
'test-run-wasm-simd/RunWasm_I16x8ConvertI32x4_compiled': [SKIP],
'test-run-wasm-simd/RunWasm_I8x16ConvertI16x8_compiled': [SKIP],
'test-run-wasm-simd/RunWasm_ReductionTest4_compiled': [SKIP],
'test-run-wasm-simd/RunWasm_ReductionTest8_compiled': [SKIP],
'test-run-wasm-simd/RunWasm_ReductionTest16_compiled': [SKIP],
......
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