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

Side by Side Diff: test/cctest/wasm/test-run-wasm-simd.cc

Issue 2683713003: [Turbofan] Add more non-arithmetic SIMD operations. (Closed)
Patch Set: Rebase. 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 unified diff | Download patch
« no previous file with comments | « src/wasm/wasm-opcodes.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 the V8 project authors. All rights reserved. 1 // Copyright 2016 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "src/wasm/wasm-macro-gen.h" 5 #include "src/wasm/wasm-macro-gen.h"
6 6
7 #include "test/cctest/cctest.h" 7 #include "test/cctest/cctest.h"
8 #include "test/cctest/compiler/value-helper.h" 8 #include "test/cctest/compiler/value-helper.h"
9 #include "test/cctest/wasm/wasm-run-utils.h" 9 #include "test/cctest/wasm/wasm-run-utils.h"
10 10
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 using UnsignedT = typename std::make_unsigned<T>::type; 180 using UnsignedT = typename std::make_unsigned<T>::type;
181 return Clamp<UnsignedT>(UnsignedWiden(a) + UnsignedWiden(b)); 181 return Clamp<UnsignedT>(UnsignedWiden(a) + UnsignedWiden(b));
182 } 182 }
183 183
184 template <typename T> 184 template <typename T>
185 T UnsignedSubSaturate(T a, T b) { 185 T UnsignedSubSaturate(T a, T b) {
186 using UnsignedT = typename std::make_unsigned<T>::type; 186 using UnsignedT = typename std::make_unsigned<T>::type;
187 return Clamp<UnsignedT>(UnsignedWiden(a) - UnsignedWiden(b)); 187 return Clamp<UnsignedT>(UnsignedWiden(a) - UnsignedWiden(b));
188 } 188 }
189 189
190 template <typename T>
191 T And(T a, T b) {
192 return a & b;
193 }
194
195 template <typename T>
196 T Or(T a, T b) {
197 return a | b;
198 }
199
200 template <typename T>
201 T Xor(T a, T b) {
202 return a ^ b;
203 }
204
205 template <typename T>
206 T Not(T a) {
207 return ~a;
208 }
209
190 } // namespace 210 } // namespace
191 211
192 // TODO(gdeepti): These are tests using sample values to verify functional 212 // TODO(gdeepti): These are tests using sample values to verify functional
193 // correctness of opcodes, add more tests for a range of values and macroize 213 // correctness of opcodes, add more tests for a range of values and macroize
194 // tests. 214 // tests.
195 215
196 // TODO(bbudge) Figure out how to compare floats in Wasm code that can handle 216 // TODO(bbudge) Figure out how to compare floats in Wasm code that can handle
197 // NaNs. For now, our tests avoid using NaNs. 217 // NaNs. For now, our tests avoid using NaNs.
198 #define WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lane_value, lane_index) \ 218 #define WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lane_value, lane_index) \
199 WASM_IF(WASM_##LANE_TYPE##_NE(WASM_GET_LOCAL(lane_value), \ 219 WASM_IF(WASM_##LANE_TYPE##_NE(WASM_GET_LOCAL(lane_value), \
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
257 277
258 #define WASM_SIMD_CHECK4_F32(TYPE, value, lv0, lv1, lv2, lv3) \ 278 #define WASM_SIMD_CHECK4_F32(TYPE, value, lv0, lv1, lv2, lv3) \
259 WASM_SIMD_CHECK_F32_LANE(TYPE, value, lv0, 0) \ 279 WASM_SIMD_CHECK_F32_LANE(TYPE, value, lv0, 0) \
260 , WASM_SIMD_CHECK_F32_LANE(TYPE, value, lv1, 1), \ 280 , WASM_SIMD_CHECK_F32_LANE(TYPE, value, lv1, 1), \
261 WASM_SIMD_CHECK_F32_LANE(TYPE, value, lv2, 2), \ 281 WASM_SIMD_CHECK_F32_LANE(TYPE, value, lv2, 2), \
262 WASM_SIMD_CHECK_F32_LANE(TYPE, value, lv3, 3) 282 WASM_SIMD_CHECK_F32_LANE(TYPE, value, lv3, 3)
263 283
264 #define WASM_SIMD_CHECK_SPLAT4_F32(TYPE, value, lv) \ 284 #define WASM_SIMD_CHECK_SPLAT4_F32(TYPE, value, lv) \
265 WASM_SIMD_CHECK4_F32(TYPE, value, lv, lv, lv, lv) 285 WASM_SIMD_CHECK4_F32(TYPE, value, lv, lv, lv, lv)
266 286
267 #define WASM_SIMD_UNOP(opcode, x) x, kSimdPrefix, static_cast<byte>(opcode) 287 #define TO_BYTE(val) static_cast<byte>(val)
268 #define WASM_SIMD_BINOP(opcode, x, y) \ 288 #define WASM_SIMD_OP(op) kSimdPrefix, TO_BYTE(op)
269 x, y, kSimdPrefix, static_cast<byte>(opcode) 289 #define WASM_SIMD_UNOP(op, x) x, WASM_SIMD_OP(op)
270 #define WASM_SIMD_SHIFT_OP(opcode, x, shift) \ 290 #define WASM_SIMD_BINOP(op, x, y) x, y, WASM_SIMD_OP(op)
271 x, kSimdPrefix, static_cast<byte>(opcode), static_cast<byte>(shift) 291 #define WASM_SIMD_SHIFT_OP(op, shift, x) x, WASM_SIMD_OP(op), TO_BYTE(shift)
292 #define WASM_SIMD_SELECT(format, x, y, z) \
293 x, y, z, WASM_SIMD_OP(kExprS##format##Select)
294
295 #define WASM_SIMD_I16x8_SPLAT(x) x, WASM_SIMD_OP(kExprI16x8Splat)
296 #define WASM_SIMD_I16x8_EXTRACT_LANE(lane, x) \
297 x, WASM_SIMD_OP(kExprI16x8ExtractLane), TO_BYTE(lane)
298 #define WASM_SIMD_I16x8_REPLACE_LANE(lane, x, y) \
299 x, y, WASM_SIMD_OP(kExprI16x8ReplaceLane), TO_BYTE(lane)
300 #define WASM_SIMD_I8x16_SPLAT(x) x, WASM_SIMD_OP(kExprI8x16Splat)
301 #define WASM_SIMD_I8x16_EXTRACT_LANE(lane, x) \
302 x, WASM_SIMD_OP(kExprI8x16ExtractLane), TO_BYTE(lane)
303 #define WASM_SIMD_I8x16_REPLACE_LANE(lane, x, y) \
304 x, y, WASM_SIMD_OP(kExprI8x16ReplaceLane), TO_BYTE(lane)
305
306 #define WASM_SIMD_F32x4_FROM_I32x4(x) x, WASM_SIMD_OP(kExprF32x4SConvertI32x4)
307 #define WASM_SIMD_F32x4_FROM_U32x4(x) x, WASM_SIMD_OP(kExprF32x4UConvertI32x4)
308 #define WASM_SIMD_I32x4_FROM_F32x4(x) x, WASM_SIMD_OP(kExprI32x4SConvertF32x4)
309 #define WASM_SIMD_U32x4_FROM_F32x4(x) x, WASM_SIMD_OP(kExprI32x4UConvertF32x4)
272 310
273 #if V8_TARGET_ARCH_ARM 311 #if V8_TARGET_ARCH_ARM
274 WASM_EXEC_TEST(F32x4Splat) { 312 WASM_EXEC_TEST(F32x4Splat) {
275 FLAG_wasm_simd_prototype = true; 313 FLAG_wasm_simd_prototype = true;
276 314
277 WasmRunner<int32_t, float> r(kExecuteCompiled); 315 WasmRunner<int32_t, float> r(kExecuteCompiled);
278 byte lane_val = 0; 316 byte lane_val = 0;
279 byte simd = r.AllocateLocal(kWasmS128); 317 byte simd = r.AllocateLocal(kWasmS128);
280 BUILD(r, 318 BUILD(r,
281 WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(lane_val))), 319 WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(lane_val))),
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
327 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd1, expected_signed), 365 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd1, expected_signed),
328 WASM_SET_LOCAL(simd2, WASM_SIMD_F32x4_FROM_U32x4(WASM_GET_LOCAL(simd0))), 366 WASM_SET_LOCAL(simd2, WASM_SIMD_F32x4_FROM_U32x4(WASM_GET_LOCAL(simd0))),
329 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd2, expected_unsigned), WASM_ONE); 367 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd2, expected_unsigned), WASM_ONE);
330 368
331 FOR_INT32_INPUTS(i) { 369 FOR_INT32_INPUTS(i) {
332 CHECK_EQ(1, r.Call(*i, static_cast<float>(*i), 370 CHECK_EQ(1, r.Call(*i, static_cast<float>(*i),
333 static_cast<float>(static_cast<uint32_t>(*i)))); 371 static_cast<float>(static_cast<uint32_t>(*i))));
334 } 372 }
335 } 373 }
336 374
337 WASM_EXEC_TEST(S32x4Select) {
338 FLAG_wasm_simd_prototype = true;
339 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
340 byte val1 = 0;
341 byte val2 = 1;
342 byte mask = r.AllocateLocal(kWasmS128);
343 byte src1 = r.AllocateLocal(kWasmS128);
344 byte src2 = r.AllocateLocal(kWasmS128);
345 BUILD(r,
346
347 WASM_SET_LOCAL(mask, WASM_SIMD_I32x4_SPLAT(WASM_ZERO)),
348 WASM_SET_LOCAL(src1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(val1))),
349 WASM_SET_LOCAL(src2, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(val2))),
350 WASM_SET_LOCAL(mask, WASM_SIMD_I32x4_REPLACE_LANE(
351 1, WASM_GET_LOCAL(mask), WASM_I32V(-1))),
352 WASM_SET_LOCAL(mask, WASM_SIMD_I32x4_REPLACE_LANE(
353 2, WASM_GET_LOCAL(mask), WASM_I32V(-1))),
354 WASM_SET_LOCAL(mask, WASM_SIMD_S32x4_SELECT(WASM_GET_LOCAL(mask),
355 WASM_GET_LOCAL(src1),
356 WASM_GET_LOCAL(src2))),
357 WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val2, 0),
358 WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val1, 1),
359 WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val1, 2),
360 WASM_SIMD_CHECK_LANE(I32x4, mask, I32, val2, 3), WASM_ONE);
361
362 CHECK_EQ(1, r.Call(0x1234, 0x5678));
363 }
364
365 void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op) { 375 void RunF32x4UnOpTest(WasmOpcode simd_op, FloatUnOp expected_op) {
366 FLAG_wasm_simd_prototype = true; 376 FLAG_wasm_simd_prototype = true;
367 WasmRunner<int32_t, float, float> r(kExecuteCompiled); 377 WasmRunner<int32_t, float, float> r(kExecuteCompiled);
368 byte a = 0; 378 byte a = 0;
369 byte expected = 1; 379 byte expected = 1;
370 byte simd = r.AllocateLocal(kWasmS128); 380 byte simd = r.AllocateLocal(kWasmS128);
371 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), 381 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
372 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), 382 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
373 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, expected), WASM_ONE); 383 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, expected), WASM_ONE);
374 384
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
746 byte expected = 1; 756 byte expected = 1;
747 byte simd = r.AllocateLocal(kWasmS128); 757 byte simd = r.AllocateLocal(kWasmS128);
748 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 758 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
749 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), 759 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
750 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); 760 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE);
751 761
752 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } 762 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); }
753 } 763 }
754 764
755 WASM_EXEC_TEST(I32x4Neg) { RunI32x4UnOpTest(kExprI32x4Neg, Negate); } 765 WASM_EXEC_TEST(I32x4Neg) { RunI32x4UnOpTest(kExprI32x4Neg, Negate); }
766
767 WASM_EXEC_TEST(S128Not) { RunI32x4UnOpTest(kExprS128Not, Not); }
756 #endif // V8_TARGET_ARCH_ARM 768 #endif // V8_TARGET_ARCH_ARM
757 769
758 void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { 770 void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) {
759 FLAG_wasm_simd_prototype = true; 771 FLAG_wasm_simd_prototype = true;
760 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); 772 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
761 byte a = 0; 773 byte a = 0;
762 byte b = 1; 774 byte b = 1;
763 byte expected = 2; 775 byte expected = 2;
764 byte simd0 = r.AllocateLocal(kWasmS128); 776 byte simd0 = r.AllocateLocal(kWasmS128);
765 byte simd1 = r.AllocateLocal(kWasmS128); 777 byte simd1 = r.AllocateLocal(kWasmS128);
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
814 WASM_EXEC_TEST(Ui32x4GreaterEqual) { 826 WASM_EXEC_TEST(Ui32x4GreaterEqual) {
815 RunI32x4BinOpTest(kExprI32x4GeU, UnsignedGreaterEqual); 827 RunI32x4BinOpTest(kExprI32x4GeU, UnsignedGreaterEqual);
816 } 828 }
817 829
818 WASM_EXEC_TEST(Ui32x4Less) { RunI32x4BinOpTest(kExprI32x4LtU, UnsignedLess); } 830 WASM_EXEC_TEST(Ui32x4Less) { RunI32x4BinOpTest(kExprI32x4LtU, UnsignedLess); }
819 831
820 WASM_EXEC_TEST(Ui32x4LessEqual) { 832 WASM_EXEC_TEST(Ui32x4LessEqual) {
821 RunI32x4BinOpTest(kExprI32x4LeU, UnsignedLessEqual); 833 RunI32x4BinOpTest(kExprI32x4LeU, UnsignedLessEqual);
822 } 834 }
823 835
836 WASM_EXEC_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); }
837
838 WASM_EXEC_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); }
839
840 WASM_EXEC_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); }
841
824 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op, 842 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op,
825 int shift) { 843 int shift) {
826 FLAG_wasm_simd_prototype = true; 844 FLAG_wasm_simd_prototype = true;
827 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 845 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
828 byte a = 0; 846 byte a = 0;
829 byte expected = 1; 847 byte expected = 1;
830 byte simd = r.AllocateLocal(kWasmS128); 848 byte simd = r.AllocateLocal(kWasmS128);
831 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 849 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
832 WASM_SET_LOCAL( 850 WASM_SET_LOCAL(
833 simd, WASM_SIMD_SHIFT_OP(simd_op, WASM_GET_LOCAL(simd), shift)), 851 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))),
834 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); 852 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE);
835 853
836 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } 854 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); }
837 } 855 }
838 856
839 WASM_EXEC_TEST(I32x4Shl) { 857 WASM_EXEC_TEST(I32x4Shl) {
840 RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1); 858 RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1);
841 } 859 }
842 860
843 WASM_EXEC_TEST(I32x4ShrS) { 861 WASM_EXEC_TEST(I32x4ShrS) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
946 964
947 void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op, 965 void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op,
948 int shift) { 966 int shift) {
949 FLAG_wasm_simd_prototype = true; 967 FLAG_wasm_simd_prototype = true;
950 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 968 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
951 byte a = 0; 969 byte a = 0;
952 byte expected = 1; 970 byte expected = 1;
953 byte simd = r.AllocateLocal(kWasmS128); 971 byte simd = r.AllocateLocal(kWasmS128);
954 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), 972 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))),
955 WASM_SET_LOCAL( 973 WASM_SET_LOCAL(
956 simd, WASM_SIMD_SHIFT_OP(simd_op, WASM_GET_LOCAL(simd), shift)), 974 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))),
957 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); 975 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE);
958 976
959 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } 977 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); }
960 } 978 }
961 979
962 WASM_EXEC_TEST(I16x8Shl) { 980 WASM_EXEC_TEST(I16x8Shl) {
963 RunI16x8ShiftOpTest(kExprI16x8Shl, LogicalShiftLeft, 1); 981 RunI16x8ShiftOpTest(kExprI16x8Shl, LogicalShiftLeft, 1);
964 } 982 }
965 983
966 WASM_EXEC_TEST(I16x8ShrS) { 984 WASM_EXEC_TEST(I16x8ShrS) {
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
1069 1087
1070 void RunI8x16ShiftOpTest(WasmOpcode simd_op, Int8ShiftOp expected_op, 1088 void RunI8x16ShiftOpTest(WasmOpcode simd_op, Int8ShiftOp expected_op,
1071 int shift) { 1089 int shift) {
1072 FLAG_wasm_simd_prototype = true; 1090 FLAG_wasm_simd_prototype = true;
1073 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 1091 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
1074 byte a = 0; 1092 byte a = 0;
1075 byte expected = 1; 1093 byte expected = 1;
1076 byte simd = r.AllocateLocal(kWasmS128); 1094 byte simd = r.AllocateLocal(kWasmS128);
1077 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), 1095 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))),
1078 WASM_SET_LOCAL( 1096 WASM_SET_LOCAL(
1079 simd, WASM_SIMD_SHIFT_OP(simd_op, WASM_GET_LOCAL(simd), shift)), 1097 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))),
1080 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE); 1098 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE);
1081 1099
1082 FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } 1100 FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); }
1083 } 1101 }
1084 1102
1085 WASM_EXEC_TEST(I8x16Shl) { 1103 WASM_EXEC_TEST(I8x16Shl) {
1086 RunI8x16ShiftOpTest(kExprI8x16Shl, LogicalShiftLeft, 1); 1104 RunI8x16ShiftOpTest(kExprI8x16Shl, LogicalShiftLeft, 1);
1087 } 1105 }
1088 1106
1089 WASM_EXEC_TEST(I8x16ShrS) { 1107 WASM_EXEC_TEST(I8x16ShrS) {
1090 RunI8x16ShiftOpTest(kExprI8x16ShrS, ArithmeticShiftRight, 1); 1108 RunI8x16ShiftOpTest(kExprI8x16ShrS, ArithmeticShiftRight, 1);
1091 } 1109 }
1092 1110
1093 WASM_EXEC_TEST(I8x16ShrU) { 1111 WASM_EXEC_TEST(I8x16ShrU) {
1094 RunI8x16ShiftOpTest(kExprI8x16ShrU, LogicalShiftRight, 1); 1112 RunI8x16ShiftOpTest(kExprI8x16ShrU, LogicalShiftRight, 1);
1095 } 1113 }
1114
1115 #define WASM_SIMD_SELECT_TEST(format) \
1116 WASM_EXEC_TEST(S##format##Select) { \
1117 FLAG_wasm_simd_prototype = true; \
1118 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); \
1119 byte val1 = 0; \
1120 byte val2 = 1; \
1121 byte mask = r.AllocateLocal(kWasmS128); \
1122 byte src1 = r.AllocateLocal(kWasmS128); \
1123 byte src2 = r.AllocateLocal(kWasmS128); \
1124 BUILD(r, WASM_SET_LOCAL(mask, WASM_SIMD_I##format##_SPLAT(WASM_ZERO)), \
1125 WASM_SET_LOCAL(src1, \
1126 WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val1))), \
1127 WASM_SET_LOCAL(src2, \
1128 WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val2))), \
1129 WASM_SET_LOCAL(mask, WASM_SIMD_I##format##_REPLACE_LANE( \
1130 1, WASM_GET_LOCAL(mask), WASM_I32V(-1))), \
1131 WASM_SET_LOCAL(mask, WASM_SIMD_I##format##_REPLACE_LANE( \
1132 2, WASM_GET_LOCAL(mask), WASM_I32V(-1))), \
1133 WASM_SET_LOCAL(mask, WASM_SIMD_SELECT(format, WASM_GET_LOCAL(mask), \
1134 WASM_GET_LOCAL(src1), \
1135 WASM_GET_LOCAL(src2))), \
1136 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 0), \
1137 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 1), \
1138 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 2), \
1139 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 3), WASM_ONE); \
1140 \
1141 CHECK_EQ(1, r.Call(0x12, 0x34)); \
1142 }
1143
1144 WASM_SIMD_SELECT_TEST(32x4)
1145 WASM_SIMD_SELECT_TEST(16x8)
1146 WASM_SIMD_SELECT_TEST(8x16)
1096 #endif // V8_TARGET_ARCH_ARM 1147 #endif // V8_TARGET_ARCH_ARM
OLDNEW
« no previous file with comments | « src/wasm/wasm-opcodes.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698