Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(319)

Unified Diff: test/cctest/wasm/test-run-wasm-simd.cc

Issue 2668013003: [Turbofan] Add more integer SIMD operations for ARM. (Closed)
Patch Set: Fix compile. Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/wasm/wasm-opcodes.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: test/cctest/wasm/test-run-wasm-simd.cc
diff --git a/test/cctest/wasm/test-run-wasm-simd.cc b/test/cctest/wasm/test-run-wasm-simd.cc
index f9cdea47da8dbe272d15a9f3fa32929b13a16a80..62caa6176e63774946a3d938d4f9f733f8820581 100644
--- a/test/cctest/wasm/test-run-wasm-simd.cc
+++ b/test/cctest/wasm/test-run-wasm-simd.cc
@@ -20,10 +20,13 @@ typedef float (*FloatBinOp)(float, float);
typedef int32_t (*FloatCompareOp)(float, float);
typedef int32_t (*Int32UnOp)(int32_t);
typedef int32_t (*Int32BinOp)(int32_t, int32_t);
+typedef int32_t (*Int32ShiftOp)(int32_t, int);
typedef int16_t (*Int16UnOp)(int16_t);
typedef int16_t (*Int16BinOp)(int16_t, int16_t);
+typedef int16_t (*Int16ShiftOp)(int16_t, int);
typedef int8_t (*Int8UnOp)(int8_t);
typedef int8_t (*Int8BinOp)(int8_t, int8_t);
+typedef int8_t (*Int8ShiftOp)(int8_t, int);
#if V8_TARGET_ARCH_ARM
// Floating point specific value functions.
@@ -54,6 +57,28 @@ T Mul(T a, T b) {
}
template <typename T>
+T Minimum(T a, T b) {
+ return a <= b ? a : b;
+}
+
+template <typename T>
+T Maximum(T a, T b) {
+ return a >= b ? a : b;
+}
+
+template <typename T>
+T UnsignedMinimum(T a, T b) {
+ using UnsignedT = typename std::make_unsigned<T>::type;
+ return static_cast<UnsignedT>(a) <= static_cast<UnsignedT>(b) ? a : b;
+}
+
+template <typename T>
+T UnsignedMaximum(T a, T b) {
+ using UnsignedT = typename std::make_unsigned<T>::type;
+ return static_cast<UnsignedT>(a) >= static_cast<UnsignedT>(b) ? a : b;
+}
+
+template <typename T>
T Equal(T a, T b) {
return a == b ? -1 : 0;
}
@@ -107,6 +132,61 @@ T UnsignedLessEqual(T a, T b) {
return static_cast<UnsignedT>(a) <= static_cast<UnsignedT>(b) ? -1 : 0;
}
+template <typename T>
+T LogicalShiftLeft(T a, int shift) {
+ return a << shift;
+}
+
+template <typename T>
+T LogicalShiftRight(T a, int shift) {
+ using UnsignedT = typename std::make_unsigned<T>::type;
+ return static_cast<UnsignedT>(a) >> shift;
+}
+
+template <typename T>
+int64_t Widen(T value) {
+ static_assert(sizeof(int64_t) > sizeof(T), "T must be int32_t or smaller");
+ return static_cast<int64_t>(value);
+}
+
+template <typename T>
+int64_t UnsignedWiden(T value) {
+ static_assert(sizeof(int64_t) > sizeof(T), "T must be int32_t or smaller");
+ using UnsignedT = typename std::make_unsigned<T>::type;
+ return static_cast<int64_t>(static_cast<UnsignedT>(value));
+}
+
+template <typename T>
+T Clamp(int64_t value) {
+ static_assert(sizeof(int64_t) > sizeof(T), "T must be int32_t or smaller");
+ int64_t min = static_cast<int64_t>(std::numeric_limits<T>::min());
+ int64_t max = static_cast<int64_t>(std::numeric_limits<T>::max());
+ int64_t clamped = std::max(min, std::min(max, value));
+ return static_cast<T>(clamped);
+}
+
+template <typename T>
+T AddSaturate(T a, T b) {
+ return Clamp<T>(Widen(a) + Widen(b));
+}
+
+template <typename T>
+T SubSaturate(T a, T b) {
+ return Clamp<T>(Widen(a) - Widen(b));
+}
+
+template <typename T>
+T UnsignedAddSaturate(T a, T b) {
+ using UnsignedT = typename std::make_unsigned<T>::type;
+ return Clamp<UnsignedT>(UnsignedWiden(a) + UnsignedWiden(b));
+}
+
+template <typename T>
+T UnsignedSubSaturate(T a, T b) {
+ using UnsignedT = typename std::make_unsigned<T>::type;
+ return Clamp<UnsignedT>(UnsignedWiden(a) - UnsignedWiden(b));
+}
+
} // namespace
// TODO(gdeepti): These are tests using sample values to verify functional
@@ -184,6 +264,12 @@ T UnsignedLessEqual(T a, T b) {
#define WASM_SIMD_CHECK_SPLAT4_F32(TYPE, value, lv) \
WASM_SIMD_CHECK4_F32(TYPE, value, lv, lv, lv, lv)
+#define WASM_SIMD_UNOP(opcode, x) x, kSimdPrefix, static_cast<byte>(opcode)
+#define WASM_SIMD_BINOP(opcode, x, y) \
+ x, y, kSimdPrefix, static_cast<byte>(opcode)
+#define WASM_SIMD_SHIFT_OP(opcode, x, shift) \
+ x, kSimdPrefix, static_cast<byte>(opcode), static_cast<byte>(shift)
+
#if V8_TARGET_ARCH_ARM
WASM_EXEC_TEST(F32x4Splat) {
FLAG_wasm_simd_prototype = true;
@@ -283,8 +369,7 @@ void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op) {
byte expected = 1;
byte simd = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
- WASM_SET_LOCAL(simd,
- WASM_SIMD_UNOP(simd_op & 0xffu, WASM_GET_LOCAL(simd))),
+ WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, expected), WASM_ONE);
FOR_FLOAT32_INPUTS(i) {
@@ -306,9 +391,8 @@ void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) {
byte simd1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))),
- WASM_SET_LOCAL(simd1,
- WASM_SIMD_BINOP(simd_op & 0xffu, WASM_GET_LOCAL(simd0),
- WASM_GET_LOCAL(simd1))),
+ WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
+ WASM_GET_LOCAL(simd1))),
WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd1, expected), WASM_ONE);
FOR_FLOAT32_INPUTS(i) {
@@ -338,9 +422,8 @@ void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) {
byte simd1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))),
- WASM_SET_LOCAL(simd1,
- WASM_SIMD_BINOP(simd_op & 0xffu, WASM_GET_LOCAL(simd0),
- WASM_GET_LOCAL(simd1))),
+ WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
+ WASM_GET_LOCAL(simd1))),
WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE);
FOR_FLOAT32_INPUTS(i) {
@@ -663,8 +746,7 @@ void RunI32x4UnOpTest(WasmOpcode simd_op, Int32UnOp expected_op) {
byte expected = 1;
byte simd = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
- WASM_SET_LOCAL(simd,
- WASM_SIMD_UNOP(simd_op & 0xffu, WASM_GET_LOCAL(simd))),
+ WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE);
FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); }
@@ -683,9 +765,8 @@ void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) {
byte simd1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))),
- WASM_SET_LOCAL(simd1,
- WASM_SIMD_BINOP(simd_op & 0xffu, WASM_GET_LOCAL(simd0),
- WASM_GET_LOCAL(simd1))),
+ WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
+ WASM_GET_LOCAL(simd1))),
WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE);
FOR_INT32_INPUTS(i) {
@@ -700,6 +781,10 @@ WASM_EXEC_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); }
#if V8_TARGET_ARCH_ARM
WASM_EXEC_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); }
+WASM_EXEC_TEST(I32x4Min) { RunI32x4BinOpTest(kExprI32x4MinS, Minimum); }
+
+WASM_EXEC_TEST(I32x4Max) { RunI32x4BinOpTest(kExprI32x4MaxS, Maximum); }
+
WASM_EXEC_TEST(I32x4Equal) { RunI32x4BinOpTest(kExprI32x4Eq, Equal); }
WASM_EXEC_TEST(I32x4NotEqual) { RunI32x4BinOpTest(kExprI32x4Ne, NotEqual); }
@@ -714,6 +799,14 @@ WASM_EXEC_TEST(I32x4Less) { RunI32x4BinOpTest(kExprI32x4LtS, Less); }
WASM_EXEC_TEST(I32x4LessEqual) { RunI32x4BinOpTest(kExprI32x4LeS, LessEqual); }
+WASM_EXEC_TEST(Ui32x4Min) {
+ RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum);
+}
+
+WASM_EXEC_TEST(Ui32x4Max) {
+ RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum);
+}
+
WASM_EXEC_TEST(Ui32x4Greater) {
RunI32x4BinOpTest(kExprI32x4GtU, UnsignedGreater);
}
@@ -728,6 +821,33 @@ WASM_EXEC_TEST(Ui32x4LessEqual) {
RunI32x4BinOpTest(kExprI32x4LeU, UnsignedLessEqual);
}
+void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op,
+ int shift) {
+ FLAG_wasm_simd_prototype = true;
+ WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
+ byte a = 0;
+ byte expected = 1;
+ byte simd = r.AllocateLocal(kWasmS128);
+ BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
+ WASM_SET_LOCAL(
+ simd, WASM_SIMD_SHIFT_OP(simd_op, WASM_GET_LOCAL(simd), shift)),
+ WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE);
+
+ FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); }
+}
+
+WASM_EXEC_TEST(I32x4Shl) {
+ RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1);
+}
+
+WASM_EXEC_TEST(I32x4ShrS) {
+ RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1);
+}
+
+WASM_EXEC_TEST(I32x4ShrU) {
+ RunI32x4ShiftOpTest(kExprI32x4ShrU, LogicalShiftRight, 1);
+}
+
void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
@@ -735,8 +855,7 @@ void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) {
byte expected = 1;
byte simd = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))),
- WASM_SET_LOCAL(simd,
- WASM_SIMD_UNOP(simd_op & 0xffu, WASM_GET_LOCAL(simd))),
+ WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE);
FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); }
@@ -754,9 +873,8 @@ void RunI16x8BinOpTest(WasmOpcode simd_op, Int16BinOp expected_op) {
byte simd1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))),
WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))),
- WASM_SET_LOCAL(simd1,
- WASM_SIMD_BINOP(simd_op & 0xffu, WASM_GET_LOCAL(simd0),
- WASM_GET_LOCAL(simd1))),
+ WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
+ WASM_GET_LOCAL(simd1))),
WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE);
FOR_INT16_INPUTS(i) {
@@ -766,10 +884,22 @@ void RunI16x8BinOpTest(WasmOpcode simd_op, Int16BinOp expected_op) {
WASM_EXEC_TEST(I16x8Add) { RunI16x8BinOpTest(kExprI16x8Add, Add); }
+WASM_EXEC_TEST(I16x8AddSaturate) {
+ RunI16x8BinOpTest(kExprI16x8AddSaturateS, AddSaturate);
+}
+
WASM_EXEC_TEST(I16x8Sub) { RunI16x8BinOpTest(kExprI16x8Sub, Sub); }
+WASM_EXEC_TEST(I16x8SubSaturate) {
+ RunI16x8BinOpTest(kExprI16x8SubSaturateS, SubSaturate);
+}
+
WASM_EXEC_TEST(I16x8Mul) { RunI16x8BinOpTest(kExprI16x8Mul, Mul); }
+WASM_EXEC_TEST(I16x8Min) { RunI16x8BinOpTest(kExprI16x8MinS, Minimum); }
+
+WASM_EXEC_TEST(I16x8Max) { RunI16x8BinOpTest(kExprI16x8MaxS, Maximum); }
+
WASM_EXEC_TEST(I16x8Equal) { RunI16x8BinOpTest(kExprI16x8Eq, Equal); }
WASM_EXEC_TEST(I16x8NotEqual) { RunI16x8BinOpTest(kExprI16x8Ne, NotEqual); }
@@ -784,6 +914,22 @@ WASM_EXEC_TEST(I16x8Less) { RunI16x8BinOpTest(kExprI16x8LtS, Less); }
WASM_EXEC_TEST(I16x8LessEqual) { RunI16x8BinOpTest(kExprI16x8LeS, LessEqual); }
+WASM_EXEC_TEST(Ui16x8AddSaturate) {
+ RunI16x8BinOpTest(kExprI16x8AddSaturateU, UnsignedAddSaturate);
+}
+
+WASM_EXEC_TEST(Ui16x8SubSaturate) {
+ RunI16x8BinOpTest(kExprI16x8SubSaturateU, UnsignedSubSaturate);
+}
+
+WASM_EXEC_TEST(Ui16x8Min) {
+ RunI16x8BinOpTest(kExprI16x8MinU, UnsignedMinimum);
+}
+
+WASM_EXEC_TEST(Ui16x8Max) {
+ RunI16x8BinOpTest(kExprI16x8MaxU, UnsignedMaximum);
+}
+
WASM_EXEC_TEST(Ui16x8Greater) {
RunI16x8BinOpTest(kExprI16x8GtU, UnsignedGreater);
}
@@ -798,6 +944,33 @@ WASM_EXEC_TEST(Ui16x8LessEqual) {
RunI16x8BinOpTest(kExprI16x8LeU, UnsignedLessEqual);
}
+void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op,
+ int shift) {
+ FLAG_wasm_simd_prototype = true;
+ WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
+ byte a = 0;
+ byte expected = 1;
+ byte simd = r.AllocateLocal(kWasmS128);
+ BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))),
+ WASM_SET_LOCAL(
+ simd, WASM_SIMD_SHIFT_OP(simd_op, WASM_GET_LOCAL(simd), shift)),
+ WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE);
+
+ FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); }
+}
+
+WASM_EXEC_TEST(I16x8Shl) {
+ RunI16x8ShiftOpTest(kExprI16x8Shl, LogicalShiftLeft, 1);
+}
+
+WASM_EXEC_TEST(I16x8ShrS) {
+ RunI16x8ShiftOpTest(kExprI16x8ShrS, ArithmeticShiftRight, 1);
+}
+
+WASM_EXEC_TEST(I16x8ShrU) {
+ RunI16x8ShiftOpTest(kExprI16x8ShrU, LogicalShiftRight, 1);
+}
+
void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) {
FLAG_wasm_simd_prototype = true;
WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
@@ -805,8 +978,7 @@ void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) {
byte expected = 1;
byte simd = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))),
- WASM_SET_LOCAL(simd,
- WASM_SIMD_UNOP(simd_op & 0xffu, WASM_GET_LOCAL(simd))),
+ WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE);
FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); }
@@ -824,9 +996,8 @@ void RunI8x16BinOpTest(WasmOpcode simd_op, Int8BinOp expected_op) {
byte simd1 = r.AllocateLocal(kWasmS128);
BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))),
WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))),
- WASM_SET_LOCAL(simd1,
- WASM_SIMD_BINOP(simd_op & 0xffu, WASM_GET_LOCAL(simd0),
- WASM_GET_LOCAL(simd1))),
+ WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
+ WASM_GET_LOCAL(simd1))),
WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE);
FOR_INT8_INPUTS(i) {
@@ -836,10 +1007,22 @@ void RunI8x16BinOpTest(WasmOpcode simd_op, Int8BinOp expected_op) {
WASM_EXEC_TEST(I8x16Add) { RunI8x16BinOpTest(kExprI8x16Add, Add); }
+WASM_EXEC_TEST(I8x16AddSaturate) {
+ RunI8x16BinOpTest(kExprI8x16AddSaturateS, AddSaturate);
+}
+
WASM_EXEC_TEST(I8x16Sub) { RunI8x16BinOpTest(kExprI8x16Sub, Sub); }
+WASM_EXEC_TEST(I8x16SubSaturate) {
+ RunI8x16BinOpTest(kExprI8x16SubSaturateS, SubSaturate);
+}
+
WASM_EXEC_TEST(I8x16Mul) { RunI8x16BinOpTest(kExprI8x16Mul, Mul); }
+WASM_EXEC_TEST(I8x16Min) { RunI8x16BinOpTest(kExprI8x16MinS, Minimum); }
+
+WASM_EXEC_TEST(I8x16Max) { RunI8x16BinOpTest(kExprI8x16MaxS, Maximum); }
+
WASM_EXEC_TEST(I8x16Equal) { RunI8x16BinOpTest(kExprI8x16Eq, Equal); }
WASM_EXEC_TEST(I8x16NotEqual) { RunI8x16BinOpTest(kExprI8x16Ne, NotEqual); }
@@ -854,6 +1037,22 @@ WASM_EXEC_TEST(I8x16Less) { RunI8x16BinOpTest(kExprI8x16LtS, Less); }
WASM_EXEC_TEST(I8x16LessEqual) { RunI8x16BinOpTest(kExprI8x16LeS, LessEqual); }
+WASM_EXEC_TEST(Ui8x16AddSaturate) {
+ RunI8x16BinOpTest(kExprI8x16AddSaturateU, UnsignedAddSaturate);
+}
+
+WASM_EXEC_TEST(Ui8x16SubSaturate) {
+ RunI8x16BinOpTest(kExprI8x16SubSaturateU, UnsignedSubSaturate);
+}
+
+WASM_EXEC_TEST(Ui8x16Min) {
+ RunI8x16BinOpTest(kExprI8x16MinU, UnsignedMinimum);
+}
+
+WASM_EXEC_TEST(Ui8x16Max) {
+ RunI8x16BinOpTest(kExprI8x16MaxU, UnsignedMaximum);
+}
+
WASM_EXEC_TEST(Ui8x16Greater) {
RunI8x16BinOpTest(kExprI8x16GtU, UnsignedGreater);
}
@@ -867,4 +1066,31 @@ WASM_EXEC_TEST(Ui8x16Less) { RunI8x16BinOpTest(kExprI8x16LtU, UnsignedLess); }
WASM_EXEC_TEST(Ui8x16LessEqual) {
RunI8x16BinOpTest(kExprI8x16LeU, UnsignedLessEqual);
}
+
+void RunI8x16ShiftOpTest(WasmOpcode simd_op, Int8ShiftOp expected_op,
+ int shift) {
+ FLAG_wasm_simd_prototype = true;
+ WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
+ byte a = 0;
+ byte expected = 1;
+ byte simd = r.AllocateLocal(kWasmS128);
+ BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))),
+ WASM_SET_LOCAL(
+ simd, WASM_SIMD_SHIFT_OP(simd_op, WASM_GET_LOCAL(simd), shift)),
+ WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE);
+
+ FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); }
+}
+
+WASM_EXEC_TEST(I8x16Shl) {
+ RunI8x16ShiftOpTest(kExprI8x16Shl, LogicalShiftLeft, 1);
+}
+
+WASM_EXEC_TEST(I8x16ShrS) {
+ RunI8x16ShiftOpTest(kExprI8x16ShrS, ArithmeticShiftRight, 1);
+}
+
+WASM_EXEC_TEST(I8x16ShrU) {
+ RunI8x16ShiftOpTest(kExprI8x16ShrU, LogicalShiftRight, 1);
+}
#endif // V8_TARGET_ARCH_ARM
« no previous file with comments | « src/wasm/wasm-opcodes.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698