Skip to content

Commit

Permalink
[wasm-simd] Add overflowing value tests for splats
Browse files Browse the repository at this point in the history
For I16x8Splat and I8x16Splat, the arguments takes I32, which can hold a
value larger than what should be splatted. We add tests to check that
the splatted values is the truncated I32 value (top bits masked off).

See WebAssembly/simd#151 for the updated to
proposal text.

Change-Id: Ib32770872e70c7cde2028130d2b44b416594610e
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1986200
Reviewed-by: Deepti Gandluri <gdeepti@chromium.org>
Commit-Queue: Zhi An Ng <zhin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#65642}
  • Loading branch information
ngzhian authored and Commit Bot committed Jan 8, 2020
1 parent c2fcb6d commit 30b4820
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions test/cctest/wasm/test-run-wasm-simd.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1611,6 +1611,16 @@ WASM_SIMD_TEST(I16x8Splat) {
CHECK_EQ(actual, expected);
}
}

// Test values that do not fit in a int16.
FOR_INT32_INPUTS(x) {
r.Call(x);
int16_t expected = truncate_to_int16(x);
for (int i = 0; i < 8; i++) {
int16_t actual = ReadLittleEndianValue<int16_t>(&g[i]);
CHECK_EQ(actual, expected);
}
}
}

WASM_SIMD_TEST(I16x8ReplaceLane) {
Expand Down Expand Up @@ -1660,6 +1670,16 @@ WASM_SIMD_TEST(I8x16Splat) {
CHECK_EQ(actual, expected);
}
}

// Test values that do not fit in a int16.
FOR_INT16_INPUTS(x) {
r.Call(x);
int8_t expected = truncate_to_int8(x);
for (int i = 0; i < 16; i++) {
int8_t actual = ReadLittleEndianValue<int8_t>(&g[i]);
CHECK_EQ(actual, expected);
}
}
}

WASM_SIMD_TEST(I8x16ReplaceLane) {
Expand Down

0 comments on commit 30b4820

Please sign in to comment.