Chromium Code Reviews| 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 53211ce340fbe8ca88a7f9f6448f3b264df629f5..dcad01952ff31ec44ecfcfe036ae24ee310af3e9 100644 |
| --- a/test/cctest/wasm/test-run-wasm-simd.cc |
| +++ b/test/cctest/wasm/test-run-wasm-simd.cc |
| @@ -850,9 +850,9 @@ WASM_EXEC_COMPILED_TEST(I32x4Add) { RunI32x4BinOpTest(kExprI32x4Add, Add); } |
| WASM_EXEC_COMPILED_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); } |
| -#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
| WASM_EXEC_COMPILED_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); } |
| +#if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
| WASM_EXEC_COMPILED_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); } |
| WASM_EXEC_COMPILED_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); } |
| @@ -860,7 +860,7 @@ WASM_EXEC_COMPILED_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); } |
| WASM_EXEC_COMPILED_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); } |
| #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET |
| -#if V8_TARGET_ARCH_ARM |
| +#if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 |
| WASM_EXEC_COMPILED_TEST(I32x4Min) { |
| RunI32x4BinOpTest(kExprI32x4MinS, Minimum); |
| } |
| @@ -877,8 +877,6 @@ WASM_EXEC_COMPILED_TEST(Ui32x4Max) { |
| RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum); |
| } |
| - |
| - |
| void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { |
| FLAG_wasm_simd_prototype = true; |
| WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); |
| @@ -908,6 +906,73 @@ WASM_EXEC_COMPILED_TEST(I32x4NotEqual) { |
| RunI32x4CompareOpTest(kExprI32x4Ne, NotEqual); |
| } |
| +// Test Select by making a mask where the first two lanes are true and the rest |
|
bbudge
2017/02/28 19:34:39
It would be better to adjust the #ifdefs rather th
gdeepti
2017/03/13 20:37:52
Sgtm, makes a lot more sense to move the macros, f
|
| +// false, and comparing for non-equality with zero to materialize a bool vector. |
| +#define WASM_SIMD_SELECT_TEST(format) \ |
| + WASM_EXEC_COMPILED_TEST(S##format##Select) { \ |
| + FLAG_wasm_simd_prototype = true; \ |
| + WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); \ |
| + byte val1 = 0; \ |
| + byte val2 = 1; \ |
| + byte src1 = r.AllocateLocal(kWasmS128); \ |
| + byte src2 = r.AllocateLocal(kWasmS128); \ |
| + byte zero = r.AllocateLocal(kWasmS128); \ |
| + byte mask = r.AllocateLocal(kWasmS128); \ |
| + BUILD(r, WASM_SET_LOCAL( \ |
| + src1, WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val1))), \ |
| + WASM_SET_LOCAL(src2, \ |
| + WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val2))), \ |
| + WASM_SET_LOCAL(zero, WASM_SIMD_I##format##_SPLAT(WASM_ZERO)), \ |
| + WASM_SET_LOCAL(mask, WASM_SIMD_I##format##_REPLACE_LANE( \ |
| + 1, WASM_GET_LOCAL(zero), WASM_I32V(-1))), \ |
| + WASM_SET_LOCAL(mask, WASM_SIMD_I##format##_REPLACE_LANE( \ |
| + 2, WASM_GET_LOCAL(mask), WASM_I32V(-1))), \ |
| + WASM_SET_LOCAL( \ |
| + mask, \ |
| + WASM_SIMD_SELECT(format, WASM_SIMD_BINOP(kExprI##format##Ne, \ |
| + WASM_GET_LOCAL(mask), \ |
| + WASM_GET_LOCAL(zero)), \ |
| + WASM_GET_LOCAL(src1), WASM_GET_LOCAL(src2))), \ |
| + WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 0), \ |
| + WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 1), \ |
| + WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 2), \ |
| + WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 3), WASM_ONE); \ |
| + \ |
| + CHECK_EQ(1, r.Call(0x12, 0x34)); \ |
| + } |
| + |
| +WASM_SIMD_SELECT_TEST(32x4) |
| + |
| +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, shift, 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, shift))); } |
| +} |
| + |
| +WASM_EXEC_COMPILED_TEST(I32x4Shl) { |
| + RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1); |
| +} |
| + |
| +WASM_EXEC_COMPILED_TEST(I32x4ShrS) { |
| + RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1); |
| +} |
| + |
| +WASM_EXEC_COMPILED_TEST(I32x4ShrU) { |
| + RunI32x4ShiftOpTest(kExprI32x4ShrU, LogicalShiftRight, 1); |
| +} |
| + |
| +#endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_X64 |
| + |
| +#if V8_TARGET_ARCH_ARM |
| WASM_EXEC_COMPILED_TEST(I32x4Greater) { |
| RunI32x4CompareOpTest(kExprI32x4GtS, Greater); |
| } |
| @@ -940,33 +1005,6 @@ WASM_EXEC_COMPILED_TEST(Ui32x4LessEqual) { |
| RunI32x4CompareOpTest(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, shift, 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, shift))); } |
| -} |
| - |
| -WASM_EXEC_COMPILED_TEST(I32x4Shl) { |
| - RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1); |
| -} |
| - |
| -WASM_EXEC_COMPILED_TEST(I32x4ShrS) { |
| - RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1); |
| -} |
| - |
| -WASM_EXEC_COMPILED_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); |
| @@ -1287,42 +1325,6 @@ WASM_EXEC_COMPILED_TEST(I8x16ShrU) { |
| RunI8x16ShiftOpTest(kExprI8x16ShrU, LogicalShiftRight, 1); |
| } |
| -// Test Select by making a mask where the first two lanes are true and the rest |
| -// false, and comparing for non-equality with zero to materialize a bool vector. |
| -#define WASM_SIMD_SELECT_TEST(format) \ |
| - WASM_EXEC_COMPILED_TEST(S##format##Select) { \ |
| - FLAG_wasm_simd_prototype = true; \ |
| - WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); \ |
| - byte val1 = 0; \ |
| - byte val2 = 1; \ |
| - byte src1 = r.AllocateLocal(kWasmS128); \ |
| - byte src2 = r.AllocateLocal(kWasmS128); \ |
| - byte zero = r.AllocateLocal(kWasmS128); \ |
| - byte mask = r.AllocateLocal(kWasmS128); \ |
| - BUILD(r, WASM_SET_LOCAL( \ |
| - src1, WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val1))), \ |
| - WASM_SET_LOCAL(src2, \ |
| - WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val2))), \ |
| - WASM_SET_LOCAL(zero, WASM_SIMD_I##format##_SPLAT(WASM_ZERO)), \ |
| - WASM_SET_LOCAL(mask, WASM_SIMD_I##format##_REPLACE_LANE( \ |
| - 1, WASM_GET_LOCAL(zero), WASM_I32V(-1))), \ |
| - WASM_SET_LOCAL(mask, WASM_SIMD_I##format##_REPLACE_LANE( \ |
| - 2, WASM_GET_LOCAL(mask), WASM_I32V(-1))), \ |
| - WASM_SET_LOCAL( \ |
| - mask, \ |
| - WASM_SIMD_SELECT(format, WASM_SIMD_BINOP(kExprI##format##Ne, \ |
| - WASM_GET_LOCAL(mask), \ |
| - WASM_GET_LOCAL(zero)), \ |
| - WASM_GET_LOCAL(src1), WASM_GET_LOCAL(src2))), \ |
| - WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 0), \ |
| - WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 1), \ |
| - WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 2), \ |
| - WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 3), WASM_ONE); \ |
| - \ |
| - CHECK_EQ(1, r.Call(0x12, 0x34)); \ |
| - } |
| - |
| -WASM_SIMD_SELECT_TEST(32x4) |
| WASM_SIMD_SELECT_TEST(16x8) |
| WASM_SIMD_SELECT_TEST(8x16) |
| #endif // V8_TARGET_ARCH_ARM |