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

[wasm-simd][scalar-lowering] Fix splats for i8 and i16

i8 and i16 nodes are stored in word32 nodes, when splat-ing them, we
need to make sure to handle overflow values and also sign extend them
correctly.

This fix allows us to pass simd-splat.js. It still fails on ARM
(non-simulator) due to a use of f32x4.min in the test.

Bug: v8:10507
Change-Id: I1507637a7edb33a530c84c85ee8d4acb481293e2
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/2430170Reviewed-by: 's avatarBill Budge <bbudge@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#70146}
parent 42c2fb3c
......@@ -1837,12 +1837,22 @@ void SimdScalarLowering::LowerNode(Node* node) {
case IrOpcode::kI16x8Splat:
case IrOpcode::kI8x16Splat: {
Node** rep_node = zone()->NewArray<Node*>(num_lanes);
Node* val = (HasReplacement(0, node->InputAt(0)))
? GetReplacements(node->InputAt(0))[0]
: node->InputAt(0);
// I16 and I8 are placed in Word32 nodes, we need to mask them
// accordingly, to account for overflows, then sign extend them.
if (node->opcode() == IrOpcode::kI16x8Splat) {
val = graph()->NewNode(machine()->SignExtendWord16ToInt32(),
Mask(val, kMask16));
} else if (node->opcode() == IrOpcode::kI8x16Splat) {
val = graph()->NewNode(machine()->SignExtendWord8ToInt32(),
Mask(val, kMask8));
}
for (int i = 0; i < num_lanes; ++i) {
if (HasReplacement(0, node->InputAt(0))) {
rep_node[i] = GetReplacements(node->InputAt(0))[0];
} else {
rep_node[i] = node->InputAt(0);
}
rep_node[i] = val;
}
ReplaceNode(node, rep_node, num_lanes);
break;
......@@ -1861,6 +1871,7 @@ void SimdScalarLowering::LowerNode(Node* node) {
for (int i = 1; i < num_lanes; ++i) {
rep_node[i] = nullptr;
}
ReplaceNode(node, rep_node, num_lanes);
break;
}
......
......@@ -43,7 +43,6 @@
'proposals/simd/simd_conversions' : [PASS, FAIL],
'proposals/simd/simd_lane' : [PASS, FAIL],
'proposals/simd/simd_load_splat' : [PASS, FAIL],
'proposals/simd/simd_splat' : [PASS, FAIL],
}], # ALWAYS
......@@ -52,6 +51,9 @@
'proposals/simd/simd_f32x4': [PASS, FAIL],
'proposals/simd/simd_f32x4_arith': [PASS, FAIL],
'proposals/simd/simd_f32x4_cmp': [PASS, FAIL],
# This test only has 1 problematic use of f32x4.min and f32x4.div, consider
# removing it from upstream, then we can run this test.
'proposals/simd/simd_splat' : [PASS, FAIL],
}], # arch == arm and not simulator_run
['arch == mipsel or arch == mips64el or arch == mips or arch == mips64', {
......
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