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

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

Issue 2713613005: [wasm]implement simd lowering for F32x4 and I32x4 binops (Closed)
Patch Set: rebase Created 3 years, 9 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 | « test/cctest/cctest.gyp ('k') | test/cctest/wasm/test-run-wasm-simd-lowering.cc » ('j') | 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/assembler-inl.h" 5 #include "src/assembler-inl.h"
6 #include "src/wasm/wasm-macro-gen.h" 6 #include "src/wasm/wasm-macro-gen.h"
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 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 T Sub(T a, T b) { 50 T Sub(T a, T b) {
51 return a - b; 51 return a - b;
52 } 52 }
53 53
54 template <typename T> 54 template <typename T>
55 T Mul(T a, T b) { 55 T Mul(T a, T b) {
56 return a * b; 56 return a * b;
57 } 57 }
58 58
59 template <typename T> 59 template <typename T>
60 T Div(T a, T b) {
61 return a / b;
62 }
63
64 template <typename T>
60 T Minimum(T a, T b) { 65 T Minimum(T a, T b) {
61 return a <= b ? a : b; 66 return a <= b ? a : b;
62 } 67 }
63 68
64 template <typename T> 69 template <typename T>
65 T Maximum(T a, T b) { 70 T Maximum(T a, T b) {
66 return a >= b ? a : b; 71 return a >= b ? a : b;
67 } 72 }
68 73
69 template <typename T> 74 template <typename T>
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 return a ^ b; 207 return a ^ b;
203 } 208 }
204 209
205 template <typename T> 210 template <typename T>
206 T Not(T a) { 211 T Not(T a) {
207 return ~a; 212 return ~a;
208 } 213 }
209 214
210 } // namespace 215 } // namespace
211 216
217 #if !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_X64
218 #define SIMD_LOWERING_TARGET 1
219 #else
220 #define SIMD_LOWERING_TARGET 0
221 #endif // !V8_TARGET_ARCH_ARM && !V8_TARGET_ARCH_X64
222
212 // TODO(gdeepti): These are tests using sample values to verify functional 223 // TODO(gdeepti): These are tests using sample values to verify functional
213 // correctness of opcodes, add more tests for a range of values and macroize 224 // correctness of opcodes, add more tests for a range of values and macroize
214 // tests. 225 // tests.
215 226
216 // TODO(bbudge) Figure out how to compare floats in Wasm code that can handle 227 // TODO(bbudge) Figure out how to compare floats in Wasm code that can handle
217 // NaNs. For now, our tests avoid using NaNs. 228 // NaNs. For now, our tests avoid using NaNs.
218 #define WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lane_value, lane_index) \ 229 #define WASM_SIMD_CHECK_LANE(TYPE, value, LANE_TYPE, lane_value, lane_index) \
219 WASM_IF(WASM_##LANE_TYPE##_NE(WASM_GET_LOCAL(lane_value), \ 230 WASM_IF(WASM_##LANE_TYPE##_NE(WASM_GET_LOCAL(lane_value), \
220 WASM_SIMD_##TYPE##_EXTRACT_LANE( \ 231 WASM_SIMD_##TYPE##_EXTRACT_LANE( \
221 lane_index, WASM_GET_LOCAL(value))), \ 232 lane_index, WASM_GET_LOCAL(value))), \
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 #define WASM_SIMD_SHIFT_OP(op, shift, x) x, WASM_SIMD_OP(op), TO_BYTE(shift) 303 #define WASM_SIMD_SHIFT_OP(op, shift, x) x, WASM_SIMD_OP(op), TO_BYTE(shift)
293 #define WASM_SIMD_SELECT(format, x, y, z) \ 304 #define WASM_SIMD_SELECT(format, x, y, z) \
294 x, y, z, WASM_SIMD_OP(kExprS##format##Select) 305 x, y, z, WASM_SIMD_OP(kExprS##format##Select)
295 // Since boolean vectors can't be checked directly, materialize them into 306 // Since boolean vectors can't be checked directly, materialize them into
296 // integer vectors using a Select operation. 307 // integer vectors using a Select operation.
297 #define WASM_SIMD_MATERIALIZE_BOOLS(format, x) \ 308 #define WASM_SIMD_MATERIALIZE_BOOLS(format, x) \
298 x, WASM_SIMD_I##format##_SPLAT(WASM_ONE), \ 309 x, WASM_SIMD_I##format##_SPLAT(WASM_ONE), \
299 WASM_SIMD_I##format##_SPLAT(WASM_ZERO), \ 310 WASM_SIMD_I##format##_SPLAT(WASM_ZERO), \
300 WASM_SIMD_OP(kExprS##format##Select) 311 WASM_SIMD_OP(kExprS##format##Select)
301 312
313 #define WASM_SIMD_F32x4_SPLAT(x) x, WASM_SIMD_OP(kExprF32x4Splat)
314 #define WASM_SIMD_F32x4_EXTRACT_LANE(lane, x) \
315 x, WASM_SIMD_OP(kExprF32x4ExtractLane), TO_BYTE(lane)
316 #define WASM_SIMD_F32x4_REPLACE_LANE(lane, x, y) \
317 x, y, WASM_SIMD_OP(kExprF32x4ReplaceLane), TO_BYTE(lane)
318
319 #define WASM_SIMD_I32x4_SPLAT(x) x, WASM_SIMD_OP(kExprI32x4Splat)
320 #define WASM_SIMD_I32x4_EXTRACT_LANE(lane, x) \
321 x, WASM_SIMD_OP(kExprI32x4ExtractLane), TO_BYTE(lane)
322 #define WASM_SIMD_I32x4_REPLACE_LANE(lane, x, y) \
323 x, y, WASM_SIMD_OP(kExprI32x4ReplaceLane), TO_BYTE(lane)
324
302 #define WASM_SIMD_I16x8_SPLAT(x) x, WASM_SIMD_OP(kExprI16x8Splat) 325 #define WASM_SIMD_I16x8_SPLAT(x) x, WASM_SIMD_OP(kExprI16x8Splat)
303 #define WASM_SIMD_I16x8_EXTRACT_LANE(lane, x) \ 326 #define WASM_SIMD_I16x8_EXTRACT_LANE(lane, x) \
304 x, WASM_SIMD_OP(kExprI16x8ExtractLane), TO_BYTE(lane) 327 x, WASM_SIMD_OP(kExprI16x8ExtractLane), TO_BYTE(lane)
305 #define WASM_SIMD_I16x8_REPLACE_LANE(lane, x, y) \ 328 #define WASM_SIMD_I16x8_REPLACE_LANE(lane, x, y) \
306 x, y, WASM_SIMD_OP(kExprI16x8ReplaceLane), TO_BYTE(lane) 329 x, y, WASM_SIMD_OP(kExprI16x8ReplaceLane), TO_BYTE(lane)
330
307 #define WASM_SIMD_I8x16_SPLAT(x) x, WASM_SIMD_OP(kExprI8x16Splat) 331 #define WASM_SIMD_I8x16_SPLAT(x) x, WASM_SIMD_OP(kExprI8x16Splat)
308 #define WASM_SIMD_I8x16_EXTRACT_LANE(lane, x) \ 332 #define WASM_SIMD_I8x16_EXTRACT_LANE(lane, x) \
309 x, WASM_SIMD_OP(kExprI8x16ExtractLane), TO_BYTE(lane) 333 x, WASM_SIMD_OP(kExprI8x16ExtractLane), TO_BYTE(lane)
310 #define WASM_SIMD_I8x16_REPLACE_LANE(lane, x, y) \ 334 #define WASM_SIMD_I8x16_REPLACE_LANE(lane, x, y) \
311 x, y, WASM_SIMD_OP(kExprI8x16ReplaceLane), TO_BYTE(lane) 335 x, y, WASM_SIMD_OP(kExprI8x16ReplaceLane), TO_BYTE(lane)
312 336
313 #define WASM_SIMD_F32x4_FROM_I32x4(x) x, WASM_SIMD_OP(kExprF32x4SConvertI32x4) 337 #define WASM_SIMD_F32x4_FROM_I32x4(x) x, WASM_SIMD_OP(kExprF32x4SConvertI32x4)
314 #define WASM_SIMD_F32x4_FROM_U32x4(x) x, WASM_SIMD_OP(kExprF32x4UConvertI32x4) 338 #define WASM_SIMD_F32x4_FROM_U32x4(x) x, WASM_SIMD_OP(kExprF32x4UConvertI32x4)
315 #define WASM_SIMD_I32x4_FROM_F32x4(x) x, WASM_SIMD_OP(kExprI32x4SConvertF32x4) 339 #define WASM_SIMD_I32x4_FROM_F32x4(x) x, WASM_SIMD_OP(kExprI32x4SConvertF32x4)
316 #define WASM_SIMD_U32x4_FROM_F32x4(x) x, WASM_SIMD_OP(kExprI32x4UConvertF32x4) 340 #define WASM_SIMD_U32x4_FROM_F32x4(x) x, WASM_SIMD_OP(kExprI32x4UConvertF32x4)
317 341
318 #if V8_TARGET_ARCH_ARM 342 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
319 WASM_EXEC_TEST(F32x4Splat) { 343 WASM_EXEC_COMPILED_TEST(F32x4Splat) {
320 FLAG_wasm_simd_prototype = true; 344 FLAG_wasm_simd_prototype = true;
321 345
322 WasmRunner<int32_t, float> r(kExecuteCompiled); 346 WasmRunner<int32_t, float> r(kExecuteCompiled);
323 byte lane_val = 0; 347 byte lane_val = 0;
324 byte simd = r.AllocateLocal(kWasmS128); 348 byte simd = r.AllocateLocal(kWasmS128);
325 BUILD(r, 349 BUILD(r,
326 WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(lane_val))), 350 WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(lane_val))),
327 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, lane_val), WASM_ONE); 351 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, lane_val), WASM_ONE);
328 352
329 FOR_FLOAT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } 353 FOR_FLOAT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); }
330 } 354 }
331 355
332 WASM_EXEC_TEST(F32x4ReplaceLane) { 356 WASM_EXEC_COMPILED_TEST(F32x4ReplaceLane) {
333 FLAG_wasm_simd_prototype = true; 357 FLAG_wasm_simd_prototype = true;
334 WasmRunner<int32_t, float, float> r(kExecuteCompiled); 358 WasmRunner<int32_t, float, float> r(kExecuteCompiled);
335 byte old_val = 0; 359 byte old_val = 0;
336 byte new_val = 1; 360 byte new_val = 1;
337 byte simd = r.AllocateLocal(kWasmS128); 361 byte simd = r.AllocateLocal(kWasmS128);
338 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(old_val))), 362 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(old_val))),
339 WASM_SET_LOCAL(simd, 363 WASM_SET_LOCAL(simd,
340 WASM_SIMD_F32x4_REPLACE_LANE(0, WASM_GET_LOCAL(simd), 364 WASM_SIMD_F32x4_REPLACE_LANE(0, WASM_GET_LOCAL(simd),
341 WASM_GET_LOCAL(new_val))), 365 WASM_GET_LOCAL(new_val))),
342 WASM_SIMD_CHECK4(F32x4, simd, F32, new_val, old_val, old_val, old_val), 366 WASM_SIMD_CHECK4(F32x4, simd, F32, new_val, old_val, old_val, old_val),
343 WASM_SET_LOCAL(simd, 367 WASM_SET_LOCAL(simd,
344 WASM_SIMD_F32x4_REPLACE_LANE(1, WASM_GET_LOCAL(simd), 368 WASM_SIMD_F32x4_REPLACE_LANE(1, WASM_GET_LOCAL(simd),
345 WASM_GET_LOCAL(new_val))), 369 WASM_GET_LOCAL(new_val))),
346 WASM_SIMD_CHECK4(F32x4, simd, F32, new_val, new_val, old_val, old_val), 370 WASM_SIMD_CHECK4(F32x4, simd, F32, new_val, new_val, old_val, old_val),
347 WASM_SET_LOCAL(simd, 371 WASM_SET_LOCAL(simd,
348 WASM_SIMD_F32x4_REPLACE_LANE(2, WASM_GET_LOCAL(simd), 372 WASM_SIMD_F32x4_REPLACE_LANE(2, WASM_GET_LOCAL(simd),
349 WASM_GET_LOCAL(new_val))), 373 WASM_GET_LOCAL(new_val))),
350 WASM_SIMD_CHECK4(F32x4, simd, F32, new_val, new_val, new_val, old_val), 374 WASM_SIMD_CHECK4(F32x4, simd, F32, new_val, new_val, new_val, old_val),
351 WASM_SET_LOCAL(simd, 375 WASM_SET_LOCAL(simd,
352 WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_LOCAL(simd), 376 WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_LOCAL(simd),
353 WASM_GET_LOCAL(new_val))), 377 WASM_GET_LOCAL(new_val))),
354 WASM_SIMD_CHECK_SPLAT4(F32x4, simd, F32, new_val), WASM_ONE); 378 WASM_SIMD_CHECK_SPLAT4(F32x4, simd, F32, new_val), WASM_ONE);
355 379
356 CHECK_EQ(1, r.Call(3.14159, -1.5)); 380 CHECK_EQ(1, r.Call(3.14159f, -1.5f));
357 } 381 }
382 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
358 383
384 #if V8_TARGET_ARCH_ARM
359 // Tests both signed and unsigned conversion. 385 // Tests both signed and unsigned conversion.
360 WASM_EXEC_TEST(F32x4FromInt32x4) { 386 WASM_EXEC_COMPILED_TEST(F32x4FromInt32x4) {
361 FLAG_wasm_simd_prototype = true; 387 FLAG_wasm_simd_prototype = true;
362 WasmRunner<int32_t, int32_t, float, float> r(kExecuteCompiled); 388 WasmRunner<int32_t, int32_t, float, float> r(kExecuteCompiled);
363 byte a = 0; 389 byte a = 0;
364 byte expected_signed = 1; 390 byte expected_signed = 1;
365 byte expected_unsigned = 2; 391 byte expected_unsigned = 2;
366 byte simd0 = r.AllocateLocal(kWasmS128); 392 byte simd0 = r.AllocateLocal(kWasmS128);
367 byte simd1 = r.AllocateLocal(kWasmS128); 393 byte simd1 = r.AllocateLocal(kWasmS128);
368 byte simd2 = r.AllocateLocal(kWasmS128); 394 byte simd2 = r.AllocateLocal(kWasmS128);
369 BUILD( 395 BUILD(
370 r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 396 r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
(...skipping 17 matching lines...) Expand all
388 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), 414 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
389 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), 415 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
390 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, expected), WASM_ONE); 416 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd, expected), WASM_ONE);
391 417
392 FOR_FLOAT32_INPUTS(i) { 418 FOR_FLOAT32_INPUTS(i) {
393 if (std::isnan(*i)) continue; 419 if (std::isnan(*i)) continue;
394 CHECK_EQ(1, r.Call(*i, expected_op(*i))); 420 CHECK_EQ(1, r.Call(*i, expected_op(*i)));
395 } 421 }
396 } 422 }
397 423
398 WASM_EXEC_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); } 424 WASM_EXEC_COMPILED_TEST(F32x4Abs) { RunF32x4UnOpTest(kExprF32x4Abs, std::abs); }
399 WASM_EXEC_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); } 425 WASM_EXEC_COMPILED_TEST(F32x4Neg) { RunF32x4UnOpTest(kExprF32x4Neg, Negate); }
426 #endif // V8_TARGET_ARCH_ARM
400 427
401 void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op) { 428 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
429 void RunF32x4BinOpTest(WasmOpcode simd_op, FloatBinOp expected_op,
430 bool skip_zero_inputs = false) {
402 FLAG_wasm_simd_prototype = true; 431 FLAG_wasm_simd_prototype = true;
403 WasmRunner<int32_t, float, float, float> r(kExecuteCompiled); 432 WasmRunner<int32_t, float, float, float> r(kExecuteCompiled);
404 byte a = 0; 433 byte a = 0;
405 byte b = 1; 434 byte b = 1;
406 byte expected = 2; 435 byte expected = 2;
407 byte simd0 = r.AllocateLocal(kWasmS128); 436 byte simd0 = r.AllocateLocal(kWasmS128);
408 byte simd1 = r.AllocateLocal(kWasmS128); 437 byte simd1 = r.AllocateLocal(kWasmS128);
409 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), 438 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
410 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), 439 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))),
411 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), 440 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
412 WASM_GET_LOCAL(simd1))), 441 WASM_GET_LOCAL(simd1))),
413 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd1, expected), WASM_ONE); 442 WASM_SIMD_CHECK_SPLAT4_F32(F32x4, simd1, expected), WASM_ONE);
414 443
415 FOR_FLOAT32_INPUTS(i) { 444 FOR_FLOAT32_INPUTS(i) {
416 if (std::isnan(*i)) continue; 445 if (std::isnan(*i)) continue;
417 FOR_FLOAT32_INPUTS(j) { 446 FOR_FLOAT32_INPUTS(j) {
418 if (std::isnan(*j)) continue; 447 if (std::isnan(*j)) continue;
448 if (skip_zero_inputs && std::fpclassify(*i) == FP_ZERO &&
449 std::fpclassify(*j) == FP_ZERO)
450 continue;
419 float expected = expected_op(*i, *j); 451 float expected = expected_op(*i, *j);
420 // SIMD on some platforms may handle denormalized numbers differently. 452 // SIMD on some platforms may handle denormalized numbers differently.
421 // TODO(bbudge) On platforms that flush denorms to zero, test with 453 // TODO(bbudge) On platforms that flush denorms to zero, test with
422 // expected == 0. 454 // expected == 0.
423 if (std::fpclassify(expected) == FP_SUBNORMAL) continue; 455 if (std::fpclassify(expected) == FP_SUBNORMAL) continue;
456 if (std::isnan(expected)) continue;
424 CHECK_EQ(1, r.Call(*i, *j, expected)); 457 CHECK_EQ(1, r.Call(*i, *j, expected));
425 } 458 }
426 } 459 }
427 } 460 }
428 461
429 WASM_EXEC_TEST(F32x4Add) { RunF32x4BinOpTest(kExprF32x4Add, Add); } 462 WASM_EXEC_COMPILED_TEST(F32x4Add) { RunF32x4BinOpTest(kExprF32x4Add, Add); }
430 WASM_EXEC_TEST(F32x4Sub) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); } 463 WASM_EXEC_COMPILED_TEST(F32x4Sub) { RunF32x4BinOpTest(kExprF32x4Sub, Sub); }
464 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
431 465
466 #if SIMD_LOWERING_TARGET
467 WASM_EXEC_COMPILED_TEST(F32x4Mul) { RunF32x4BinOpTest(kExprF32x4Mul, Mul); }
468 WASM_EXEC_COMPILED_TEST(F32x4Div) { RunF32x4BinOpTest(kExprF32x4Div, Div); }
469 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Min) {
470 RunF32x4BinOpTest(kExprF32x4Min, Minimum, true);
471 }
472 WASM_EXEC_COMPILED_TEST(Simd_F32x4_Max) {
473 RunF32x4BinOpTest(kExprF32x4Max, Maximum, true);
474 }
475 #endif // SIMD_LOWERING_TARGET
476
477 #if V8_TARGET_ARCH_ARM
432 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { 478 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) {
433 FLAG_wasm_simd_prototype = true; 479 FLAG_wasm_simd_prototype = true;
434 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled); 480 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled);
435 byte a = 0; 481 byte a = 0;
436 byte b = 1; 482 byte b = 1;
437 byte expected = 2; 483 byte expected = 2;
438 byte simd0 = r.AllocateLocal(kWasmS128); 484 byte simd0 = r.AllocateLocal(kWasmS128);
439 byte simd1 = r.AllocateLocal(kWasmS128); 485 byte simd1 = r.AllocateLocal(kWasmS128);
440 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), 486 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
441 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))), 487 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))),
442 WASM_SET_LOCAL(simd1, 488 WASM_SET_LOCAL(simd1,
443 WASM_SIMD_MATERIALIZE_BOOLS( 489 WASM_SIMD_MATERIALIZE_BOOLS(
444 32x4, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), 490 32x4, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
445 WASM_GET_LOCAL(simd1)))), 491 WASM_GET_LOCAL(simd1)))),
446 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE); 492 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE);
447 493
448 FOR_FLOAT32_INPUTS(i) { 494 FOR_FLOAT32_INPUTS(i) {
449 if (std::isnan(*i)) continue; 495 if (std::isnan(*i)) continue;
450 FOR_FLOAT32_INPUTS(j) { 496 FOR_FLOAT32_INPUTS(j) {
451 if (std::isnan(*j)) continue; 497 if (std::isnan(*j)) continue;
452 // SIMD on some platforms may handle denormalized numbers differently. 498 // SIMD on some platforms may handle denormalized numbers differently.
453 // Check for number pairs that are very close together. 499 // Check for number pairs that are very close together.
454 if (std::fpclassify(*i - *j) == FP_SUBNORMAL) continue; 500 if (std::fpclassify(*i - *j) == FP_SUBNORMAL) continue;
455 CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); 501 CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j)));
456 } 502 }
457 } 503 }
458 } 504 }
459 505
460 WASM_EXEC_TEST(F32x4Equal) { RunF32x4CompareOpTest(kExprF32x4Eq, Equal); } 506 WASM_EXEC_COMPILED_TEST(F32x4Equal) {
461 WASM_EXEC_TEST(F32x4NotEqual) { RunF32x4CompareOpTest(kExprF32x4Ne, NotEqual); } 507 RunF32x4CompareOpTest(kExprF32x4Eq, Equal);
508 }
509
510 WASM_EXEC_COMPILED_TEST(F32x4NotEqual) {
511 RunF32x4CompareOpTest(kExprF32x4Ne, NotEqual);
512 }
462 #endif // V8_TARGET_ARCH_ARM 513 #endif // V8_TARGET_ARCH_ARM
463 514
464 WASM_EXEC_TEST(I32x4Splat) { 515 WASM_EXEC_COMPILED_TEST(I32x4Splat) {
465 FLAG_wasm_simd_prototype = true; 516 FLAG_wasm_simd_prototype = true;
466 517
467 // Store SIMD value in a local variable, use extract lane to check lane values 518 // Store SIMD value in a local variable, use extract lane to check lane values
468 // This test is not a test for ExtractLane as Splat does not create 519 // This test is not a test for ExtractLane as Splat does not create
469 // interesting SIMD values. 520 // interesting SIMD values.
470 // 521 //
471 // SetLocal(1, I32x4Splat(Local(0))); 522 // SetLocal(1, I32x4Splat(Local(0)));
472 // For each lane index 523 // For each lane index
473 // if(Local(0) != I32x4ExtractLane(Local(1), index) 524 // if(Local(0) != I32x4ExtractLane(Local(1), index)
474 // return 0 525 // return 0
475 // 526 //
476 // return 1 527 // return 1
477 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); 528 WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
478 byte lane_val = 0; 529 byte lane_val = 0;
479 byte simd = r.AllocateLocal(kWasmS128); 530 byte simd = r.AllocateLocal(kWasmS128);
480 BUILD(r, 531 BUILD(r,
481 WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(lane_val))), 532 WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(lane_val))),
482 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, lane_val), WASM_ONE); 533 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, lane_val), WASM_ONE);
483 534
484 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } 535 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); }
485 } 536 }
486 537
487 WASM_EXEC_TEST(I32x4ReplaceLane) { 538 WASM_EXEC_COMPILED_TEST(I32x4ReplaceLane) {
488 FLAG_wasm_simd_prototype = true; 539 FLAG_wasm_simd_prototype = true;
489 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 540 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
490 byte old_val = 0; 541 byte old_val = 0;
491 byte new_val = 1; 542 byte new_val = 1;
492 byte simd = r.AllocateLocal(kWasmS128); 543 byte simd = r.AllocateLocal(kWasmS128);
493 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(old_val))), 544 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(old_val))),
494 WASM_SET_LOCAL(simd, 545 WASM_SET_LOCAL(simd,
495 WASM_SIMD_I32x4_REPLACE_LANE(0, WASM_GET_LOCAL(simd), 546 WASM_SIMD_I32x4_REPLACE_LANE(0, WASM_GET_LOCAL(simd),
496 WASM_GET_LOCAL(new_val))), 547 WASM_GET_LOCAL(new_val))),
497 WASM_SIMD_CHECK4(I32x4, simd, I32, new_val, old_val, old_val, old_val), 548 WASM_SIMD_CHECK4(I32x4, simd, I32, new_val, old_val, old_val, old_val),
498 WASM_SET_LOCAL(simd, 549 WASM_SET_LOCAL(simd,
499 WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_LOCAL(simd), 550 WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_LOCAL(simd),
500 WASM_GET_LOCAL(new_val))), 551 WASM_GET_LOCAL(new_val))),
501 WASM_SIMD_CHECK4(I32x4, simd, I32, new_val, new_val, old_val, old_val), 552 WASM_SIMD_CHECK4(I32x4, simd, I32, new_val, new_val, old_val, old_val),
502 WASM_SET_LOCAL(simd, 553 WASM_SET_LOCAL(simd,
503 WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(simd), 554 WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(simd),
504 WASM_GET_LOCAL(new_val))), 555 WASM_GET_LOCAL(new_val))),
505 WASM_SIMD_CHECK4(I32x4, simd, I32, new_val, new_val, new_val, old_val), 556 WASM_SIMD_CHECK4(I32x4, simd, I32, new_val, new_val, new_val, old_val),
506 WASM_SET_LOCAL(simd, 557 WASM_SET_LOCAL(simd,
507 WASM_SIMD_I32x4_REPLACE_LANE(3, WASM_GET_LOCAL(simd), 558 WASM_SIMD_I32x4_REPLACE_LANE(3, WASM_GET_LOCAL(simd),
508 WASM_GET_LOCAL(new_val))), 559 WASM_GET_LOCAL(new_val))),
509 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, new_val), WASM_ONE); 560 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, new_val), WASM_ONE);
510 561
511 CHECK_EQ(1, r.Call(1, 2)); 562 CHECK_EQ(1, r.Call(1, 2));
512 } 563 }
513 564
514 #if V8_TARGET_ARCH_ARM 565 #if V8_TARGET_ARCH_ARM
515 566
516 WASM_EXEC_TEST(I16x8Splat) { 567 WASM_EXEC_COMPILED_TEST(I16x8Splat) {
517 FLAG_wasm_simd_prototype = true; 568 FLAG_wasm_simd_prototype = true;
518 569
519 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); 570 WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
520 byte lane_val = 0; 571 byte lane_val = 0;
521 byte simd = r.AllocateLocal(kWasmS128); 572 byte simd = r.AllocateLocal(kWasmS128);
522 BUILD(r, 573 BUILD(r,
523 WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(lane_val))), 574 WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(lane_val))),
524 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, lane_val), WASM_ONE); 575 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, lane_val), WASM_ONE);
525 576
526 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } 577 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); }
527 } 578 }
528 579
529 WASM_EXEC_TEST(I16x8ReplaceLane) { 580 WASM_EXEC_COMPILED_TEST(I16x8ReplaceLane) {
530 FLAG_wasm_simd_prototype = true; 581 FLAG_wasm_simd_prototype = true;
531 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 582 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
532 byte old_val = 0; 583 byte old_val = 0;
533 byte new_val = 1; 584 byte new_val = 1;
534 byte simd = r.AllocateLocal(kWasmS128); 585 byte simd = r.AllocateLocal(kWasmS128);
535 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(old_val))), 586 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(old_val))),
536 WASM_SET_LOCAL(simd, 587 WASM_SET_LOCAL(simd,
537 WASM_SIMD_I16x8_REPLACE_LANE(0, WASM_GET_LOCAL(simd), 588 WASM_SIMD_I16x8_REPLACE_LANE(0, WASM_GET_LOCAL(simd),
538 WASM_GET_LOCAL(new_val))), 589 WASM_GET_LOCAL(new_val))),
539 WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, old_val, old_val, old_val, 590 WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, old_val, old_val, old_val,
(...skipping 29 matching lines...) Expand all
569 WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, new_val, new_val, 620 WASM_SIMD_CHECK8(I16x8, simd, I32, new_val, new_val, new_val, new_val,
570 new_val, new_val, new_val, old_val), 621 new_val, new_val, new_val, old_val),
571 WASM_SET_LOCAL(simd, 622 WASM_SET_LOCAL(simd,
572 WASM_SIMD_I16x8_REPLACE_LANE(7, WASM_GET_LOCAL(simd), 623 WASM_SIMD_I16x8_REPLACE_LANE(7, WASM_GET_LOCAL(simd),
573 WASM_GET_LOCAL(new_val))), 624 WASM_GET_LOCAL(new_val))),
574 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, new_val), WASM_ONE); 625 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, new_val), WASM_ONE);
575 626
576 CHECK_EQ(1, r.Call(1, 2)); 627 CHECK_EQ(1, r.Call(1, 2));
577 } 628 }
578 629
579 WASM_EXEC_TEST(I8x16Splat) { 630 WASM_EXEC_COMPILED_TEST(I8x16Splat) {
580 FLAG_wasm_simd_prototype = true; 631 FLAG_wasm_simd_prototype = true;
581 632
582 WasmRunner<int32_t, int32_t> r(kExecuteCompiled); 633 WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
583 byte lane_val = 0; 634 byte lane_val = 0;
584 byte simd = r.AllocateLocal(kWasmS128); 635 byte simd = r.AllocateLocal(kWasmS128);
585 BUILD(r, 636 BUILD(r,
586 WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(lane_val))), 637 WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(lane_val))),
587 WASM_SIMD_CHECK_SPLAT8(I8x16, simd, I32, lane_val), WASM_ONE); 638 WASM_SIMD_CHECK_SPLAT8(I8x16, simd, I32, lane_val), WASM_ONE);
588 639
589 FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); } 640 FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i)); }
590 } 641 }
591 642
592 WASM_EXEC_TEST(I8x16ReplaceLane) { 643 WASM_EXEC_COMPILED_TEST(I8x16ReplaceLane) {
593 FLAG_wasm_simd_prototype = true; 644 FLAG_wasm_simd_prototype = true;
594 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 645 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
595 byte old_val = 0; 646 byte old_val = 0;
596 byte new_val = 1; 647 byte new_val = 1;
597 byte simd = r.AllocateLocal(kWasmS128); 648 byte simd = r.AllocateLocal(kWasmS128);
598 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(old_val))), 649 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(old_val))),
599 WASM_SET_LOCAL(simd, 650 WASM_SET_LOCAL(simd,
600 WASM_SIMD_I8x16_REPLACE_LANE(0, WASM_GET_LOCAL(simd), 651 WASM_SIMD_I8x16_REPLACE_LANE(0, WASM_GET_LOCAL(simd),
601 WASM_GET_LOCAL(new_val))), 652 WASM_GET_LOCAL(new_val))),
602 WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, old_val, old_val, old_val, 653 WASM_SIMD_CHECK16(I8x16, simd, I32, new_val, old_val, old_val, old_val,
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
728 int32_t result = 779 int32_t result =
729 unsigned_integer ? static_cast<uint32_t>(val) : static_cast<int32_t>(val); 780 unsigned_integer ? static_cast<uint32_t>(val) : static_cast<int32_t>(val);
730 781
731 if (!CanRoundToZeroAndConvert(val, unsigned_integer)) { 782 if (!CanRoundToZeroAndConvert(val, unsigned_integer)) {
732 result = ConvertInvalidValue(val, unsigned_integer); 783 result = ConvertInvalidValue(val, unsigned_integer);
733 } 784 }
734 return result; 785 return result;
735 } 786 }
736 787
737 // Tests both signed and unsigned conversion. 788 // Tests both signed and unsigned conversion.
738 WASM_EXEC_TEST(I32x4FromFloat32x4) { 789 WASM_EXEC_COMPILED_TEST(I32x4FromFloat32x4) {
739 FLAG_wasm_simd_prototype = true; 790 FLAG_wasm_simd_prototype = true;
740 WasmRunner<int32_t, float, int32_t, int32_t> r(kExecuteCompiled); 791 WasmRunner<int32_t, float, int32_t, int32_t> r(kExecuteCompiled);
741 byte a = 0; 792 byte a = 0;
742 byte expected_signed = 1; 793 byte expected_signed = 1;
743 byte expected_unsigned = 2; 794 byte expected_unsigned = 2;
744 byte simd0 = r.AllocateLocal(kWasmS128); 795 byte simd0 = r.AllocateLocal(kWasmS128);
745 byte simd1 = r.AllocateLocal(kWasmS128); 796 byte simd1 = r.AllocateLocal(kWasmS128);
746 byte simd2 = r.AllocateLocal(kWasmS128); 797 byte simd2 = r.AllocateLocal(kWasmS128);
747 BUILD( 798 BUILD(
748 r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))), 799 r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
(...skipping 15 matching lines...) Expand all
764 byte a = 0; 815 byte a = 0;
765 byte expected = 1; 816 byte expected = 1;
766 byte simd = r.AllocateLocal(kWasmS128); 817 byte simd = r.AllocateLocal(kWasmS128);
767 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 818 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
768 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), 819 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
769 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); 820 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE);
770 821
771 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } 822 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); }
772 } 823 }
773 824
774 WASM_EXEC_TEST(I32x4Neg) { RunI32x4UnOpTest(kExprI32x4Neg, Negate); } 825 WASM_EXEC_COMPILED_TEST(I32x4Neg) { RunI32x4UnOpTest(kExprI32x4Neg, Negate); }
775 826
776 WASM_EXEC_TEST(S128Not) { RunI32x4UnOpTest(kExprS128Not, Not); } 827 WASM_EXEC_COMPILED_TEST(S128Not) { RunI32x4UnOpTest(kExprS128Not, Not); }
777 #endif // V8_TARGET_ARCH_ARM 828 #endif // V8_TARGET_ARCH_ARM
778 829
779 void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { 830 void RunI32x4BinOpTest(WasmOpcode simd_op, Int32BinOp expected_op) {
780 FLAG_wasm_simd_prototype = true; 831 FLAG_wasm_simd_prototype = true;
781 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); 832 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
782 byte a = 0; 833 byte a = 0;
783 byte b = 1; 834 byte b = 1;
784 byte expected = 2; 835 byte expected = 2;
785 byte simd0 = r.AllocateLocal(kWasmS128); 836 byte simd0 = r.AllocateLocal(kWasmS128);
786 byte simd1 = r.AllocateLocal(kWasmS128); 837 byte simd1 = r.AllocateLocal(kWasmS128);
787 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 838 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
788 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))), 839 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))),
789 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), 840 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
790 WASM_GET_LOCAL(simd1))), 841 WASM_GET_LOCAL(simd1))),
791 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE); 842 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE);
792 843
793 FOR_INT32_INPUTS(i) { 844 FOR_INT32_INPUTS(i) {
794 FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } 845 FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); }
795 } 846 }
796 } 847 }
797 848
798 WASM_EXEC_TEST(I32x4Add) { RunI32x4BinOpTest(kExprI32x4Add, Add); } 849 WASM_EXEC_COMPILED_TEST(I32x4Add) { RunI32x4BinOpTest(kExprI32x4Add, Add); }
799 850
800 WASM_EXEC_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); } 851 WASM_EXEC_COMPILED_TEST(I32x4Sub) { RunI32x4BinOpTest(kExprI32x4Sub, Sub); }
852
853 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
854 WASM_EXEC_COMPILED_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); }
855
856 WASM_EXEC_COMPILED_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); }
857
858 WASM_EXEC_COMPILED_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); }
859
860 WASM_EXEC_COMPILED_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); }
861 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
801 862
802 #if V8_TARGET_ARCH_ARM 863 #if V8_TARGET_ARCH_ARM
803 WASM_EXEC_TEST(I32x4Mul) { RunI32x4BinOpTest(kExprI32x4Mul, Mul); } 864 WASM_EXEC_COMPILED_TEST(I32x4Min) {
865 RunI32x4BinOpTest(kExprI32x4MinS, Minimum);
866 }
804 867
805 WASM_EXEC_TEST(I32x4Min) { RunI32x4BinOpTest(kExprI32x4MinS, Minimum); } 868 WASM_EXEC_COMPILED_TEST(I32x4Max) {
869 RunI32x4BinOpTest(kExprI32x4MaxS, Maximum);
870 }
806 871
807 WASM_EXEC_TEST(I32x4Max) { RunI32x4BinOpTest(kExprI32x4MaxS, Maximum); } 872 WASM_EXEC_COMPILED_TEST(Ui32x4Min) {
808
809 WASM_EXEC_TEST(Ui32x4Min) {
810 RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum); 873 RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum);
811 } 874 }
812 875
813 WASM_EXEC_TEST(Ui32x4Max) { 876 WASM_EXEC_COMPILED_TEST(Ui32x4Max) {
814 RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum); 877 RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum);
815 } 878 }
816 879
817 WASM_EXEC_TEST(S128And) { RunI32x4BinOpTest(kExprS128And, And); }
818 880
819 WASM_EXEC_TEST(S128Or) { RunI32x4BinOpTest(kExprS128Or, Or); }
820
821 WASM_EXEC_TEST(S128Xor) { RunI32x4BinOpTest(kExprS128Xor, Xor); }
822 881
823 void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32BinOp expected_op) { 882 void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32BinOp expected_op) {
824 FLAG_wasm_simd_prototype = true; 883 FLAG_wasm_simd_prototype = true;
825 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); 884 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
826 byte a = 0; 885 byte a = 0;
827 byte b = 1; 886 byte b = 1;
828 byte expected = 2; 887 byte expected = 2;
829 byte simd0 = r.AllocateLocal(kWasmS128); 888 byte simd0 = r.AllocateLocal(kWasmS128);
830 byte simd1 = r.AllocateLocal(kWasmS128); 889 byte simd1 = r.AllocateLocal(kWasmS128);
831 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 890 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
832 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))), 891 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))),
833 WASM_SET_LOCAL(simd1, 892 WASM_SET_LOCAL(simd1,
834 WASM_SIMD_MATERIALIZE_BOOLS( 893 WASM_SIMD_MATERIALIZE_BOOLS(
835 32x4, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), 894 32x4, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
836 WASM_GET_LOCAL(simd1)))), 895 WASM_GET_LOCAL(simd1)))),
837 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE); 896 WASM_SIMD_CHECK_SPLAT4(I32x4, simd1, I32, expected), WASM_ONE);
838 897
839 FOR_INT32_INPUTS(i) { 898 FOR_INT32_INPUTS(i) {
840 FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } 899 FOR_INT32_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); }
841 } 900 }
842 } 901 }
843 902
844 WASM_EXEC_TEST(I32x4Equal) { RunI32x4CompareOpTest(kExprI32x4Eq, Equal); } 903 WASM_EXEC_COMPILED_TEST(I32x4Equal) {
904 RunI32x4CompareOpTest(kExprI32x4Eq, Equal);
905 }
845 906
846 WASM_EXEC_TEST(I32x4NotEqual) { RunI32x4CompareOpTest(kExprI32x4Ne, NotEqual); } 907 WASM_EXEC_COMPILED_TEST(I32x4NotEqual) {
908 RunI32x4CompareOpTest(kExprI32x4Ne, NotEqual);
909 }
847 910
848 WASM_EXEC_TEST(I32x4Greater) { RunI32x4CompareOpTest(kExprI32x4GtS, Greater); } 911 WASM_EXEC_COMPILED_TEST(I32x4Greater) {
912 RunI32x4CompareOpTest(kExprI32x4GtS, Greater);
913 }
849 914
850 WASM_EXEC_TEST(I32x4GreaterEqual) { 915 WASM_EXEC_COMPILED_TEST(I32x4GreaterEqual) {
851 RunI32x4CompareOpTest(kExprI32x4GeS, GreaterEqual); 916 RunI32x4CompareOpTest(kExprI32x4GeS, GreaterEqual);
852 } 917 }
853 918
854 WASM_EXEC_TEST(I32x4Less) { RunI32x4CompareOpTest(kExprI32x4LtS, Less); } 919 WASM_EXEC_COMPILED_TEST(I32x4Less) {
920 RunI32x4CompareOpTest(kExprI32x4LtS, Less);
921 }
855 922
856 WASM_EXEC_TEST(I32x4LessEqual) { 923 WASM_EXEC_COMPILED_TEST(I32x4LessEqual) {
857 RunI32x4CompareOpTest(kExprI32x4LeS, LessEqual); 924 RunI32x4CompareOpTest(kExprI32x4LeS, LessEqual);
858 } 925 }
859 926
860 WASM_EXEC_TEST(Ui32x4Greater) { 927 WASM_EXEC_COMPILED_TEST(Ui32x4Greater) {
861 RunI32x4CompareOpTest(kExprI32x4GtU, UnsignedGreater); 928 RunI32x4CompareOpTest(kExprI32x4GtU, UnsignedGreater);
862 } 929 }
863 930
864 WASM_EXEC_TEST(Ui32x4GreaterEqual) { 931 WASM_EXEC_COMPILED_TEST(Ui32x4GreaterEqual) {
865 RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual); 932 RunI32x4CompareOpTest(kExprI32x4GeU, UnsignedGreaterEqual);
866 } 933 }
867 934
868 WASM_EXEC_TEST(Ui32x4Less) { 935 WASM_EXEC_COMPILED_TEST(Ui32x4Less) {
869 RunI32x4CompareOpTest(kExprI32x4LtU, UnsignedLess); 936 RunI32x4CompareOpTest(kExprI32x4LtU, UnsignedLess);
870 } 937 }
871 938
872 WASM_EXEC_TEST(Ui32x4LessEqual) { 939 WASM_EXEC_COMPILED_TEST(Ui32x4LessEqual) {
873 RunI32x4CompareOpTest(kExprI32x4LeU, UnsignedLessEqual); 940 RunI32x4CompareOpTest(kExprI32x4LeU, UnsignedLessEqual);
874 } 941 }
875 942
876 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op, 943 void RunI32x4ShiftOpTest(WasmOpcode simd_op, Int32ShiftOp expected_op,
877 int shift) { 944 int shift) {
878 FLAG_wasm_simd_prototype = true; 945 FLAG_wasm_simd_prototype = true;
879 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 946 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
880 byte a = 0; 947 byte a = 0;
881 byte expected = 1; 948 byte expected = 1;
882 byte simd = r.AllocateLocal(kWasmS128); 949 byte simd = r.AllocateLocal(kWasmS128);
883 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 950 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
884 WASM_SET_LOCAL( 951 WASM_SET_LOCAL(
885 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), 952 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))),
886 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE); 953 WASM_SIMD_CHECK_SPLAT4(I32x4, simd, I32, expected), WASM_ONE);
887 954
888 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } 955 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); }
889 } 956 }
890 957
891 WASM_EXEC_TEST(I32x4Shl) { 958 WASM_EXEC_COMPILED_TEST(I32x4Shl) {
892 RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1); 959 RunI32x4ShiftOpTest(kExprI32x4Shl, LogicalShiftLeft, 1);
893 } 960 }
894 961
895 WASM_EXEC_TEST(I32x4ShrS) { 962 WASM_EXEC_COMPILED_TEST(I32x4ShrS) {
896 RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1); 963 RunI32x4ShiftOpTest(kExprI32x4ShrS, ArithmeticShiftRight, 1);
897 } 964 }
898 965
899 WASM_EXEC_TEST(I32x4ShrU) { 966 WASM_EXEC_COMPILED_TEST(I32x4ShrU) {
900 RunI32x4ShiftOpTest(kExprI32x4ShrU, LogicalShiftRight, 1); 967 RunI32x4ShiftOpTest(kExprI32x4ShrU, LogicalShiftRight, 1);
901 } 968 }
902 969
903 void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) { 970 void RunI16x8UnOpTest(WasmOpcode simd_op, Int16UnOp expected_op) {
904 FLAG_wasm_simd_prototype = true; 971 FLAG_wasm_simd_prototype = true;
905 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 972 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
906 byte a = 0; 973 byte a = 0;
907 byte expected = 1; 974 byte expected = 1;
908 byte simd = r.AllocateLocal(kWasmS128); 975 byte simd = r.AllocateLocal(kWasmS128);
909 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), 976 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))),
910 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), 977 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
911 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); 978 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE);
912 979
913 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } 980 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); }
914 } 981 }
915 982
916 WASM_EXEC_TEST(I16x8Neg) { RunI16x8UnOpTest(kExprI16x8Neg, Negate); } 983 WASM_EXEC_COMPILED_TEST(I16x8Neg) { RunI16x8UnOpTest(kExprI16x8Neg, Negate); }
917 984
918 void RunI16x8BinOpTest(WasmOpcode simd_op, Int16BinOp expected_op) { 985 void RunI16x8BinOpTest(WasmOpcode simd_op, Int16BinOp expected_op) {
919 FLAG_wasm_simd_prototype = true; 986 FLAG_wasm_simd_prototype = true;
920 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); 987 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
921 byte a = 0; 988 byte a = 0;
922 byte b = 1; 989 byte b = 1;
923 byte expected = 2; 990 byte expected = 2;
924 byte simd0 = r.AllocateLocal(kWasmS128); 991 byte simd0 = r.AllocateLocal(kWasmS128);
925 byte simd1 = r.AllocateLocal(kWasmS128); 992 byte simd1 = r.AllocateLocal(kWasmS128);
926 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), 993 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))),
927 WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))), 994 WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))),
928 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), 995 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
929 WASM_GET_LOCAL(simd1))), 996 WASM_GET_LOCAL(simd1))),
930 WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE); 997 WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE);
931 998
932 FOR_INT16_INPUTS(i) { 999 FOR_INT16_INPUTS(i) {
933 FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } 1000 FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); }
934 } 1001 }
935 } 1002 }
936 1003
937 WASM_EXEC_TEST(I16x8Add) { RunI16x8BinOpTest(kExprI16x8Add, Add); } 1004 WASM_EXEC_COMPILED_TEST(I16x8Add) { RunI16x8BinOpTest(kExprI16x8Add, Add); }
938 1005
939 WASM_EXEC_TEST(I16x8AddSaturate) { 1006 WASM_EXEC_COMPILED_TEST(I16x8AddSaturate) {
940 RunI16x8BinOpTest(kExprI16x8AddSaturateS, AddSaturate); 1007 RunI16x8BinOpTest(kExprI16x8AddSaturateS, AddSaturate);
941 } 1008 }
942 1009
943 WASM_EXEC_TEST(I16x8Sub) { RunI16x8BinOpTest(kExprI16x8Sub, Sub); } 1010 WASM_EXEC_COMPILED_TEST(I16x8Sub) { RunI16x8BinOpTest(kExprI16x8Sub, Sub); }
944 1011
945 WASM_EXEC_TEST(I16x8SubSaturate) { 1012 WASM_EXEC_COMPILED_TEST(I16x8SubSaturate) {
946 RunI16x8BinOpTest(kExprI16x8SubSaturateS, SubSaturate); 1013 RunI16x8BinOpTest(kExprI16x8SubSaturateS, SubSaturate);
947 } 1014 }
948 1015
949 WASM_EXEC_TEST(I16x8Mul) { RunI16x8BinOpTest(kExprI16x8Mul, Mul); } 1016 WASM_EXEC_COMPILED_TEST(I16x8Mul) { RunI16x8BinOpTest(kExprI16x8Mul, Mul); }
950 1017
951 WASM_EXEC_TEST(I16x8Min) { RunI16x8BinOpTest(kExprI16x8MinS, Minimum); } 1018 WASM_EXEC_COMPILED_TEST(I16x8Min) {
1019 RunI16x8BinOpTest(kExprI16x8MinS, Minimum);
1020 }
952 1021
953 WASM_EXEC_TEST(I16x8Max) { RunI16x8BinOpTest(kExprI16x8MaxS, Maximum); } 1022 WASM_EXEC_COMPILED_TEST(I16x8Max) {
1023 RunI16x8BinOpTest(kExprI16x8MaxS, Maximum);
1024 }
954 1025
955 WASM_EXEC_TEST(Ui16x8AddSaturate) { 1026 WASM_EXEC_COMPILED_TEST(Ui16x8AddSaturate) {
956 RunI16x8BinOpTest(kExprI16x8AddSaturateU, UnsignedAddSaturate); 1027 RunI16x8BinOpTest(kExprI16x8AddSaturateU, UnsignedAddSaturate);
957 } 1028 }
958 1029
959 WASM_EXEC_TEST(Ui16x8SubSaturate) { 1030 WASM_EXEC_COMPILED_TEST(Ui16x8SubSaturate) {
960 RunI16x8BinOpTest(kExprI16x8SubSaturateU, UnsignedSubSaturate); 1031 RunI16x8BinOpTest(kExprI16x8SubSaturateU, UnsignedSubSaturate);
961 } 1032 }
962 1033
963 WASM_EXEC_TEST(Ui16x8Min) { 1034 WASM_EXEC_COMPILED_TEST(Ui16x8Min) {
964 RunI16x8BinOpTest(kExprI16x8MinU, UnsignedMinimum); 1035 RunI16x8BinOpTest(kExprI16x8MinU, UnsignedMinimum);
965 } 1036 }
966 1037
967 WASM_EXEC_TEST(Ui16x8Max) { 1038 WASM_EXEC_COMPILED_TEST(Ui16x8Max) {
968 RunI16x8BinOpTest(kExprI16x8MaxU, UnsignedMaximum); 1039 RunI16x8BinOpTest(kExprI16x8MaxU, UnsignedMaximum);
969 } 1040 }
970 1041
971 void RunI16x8CompareOpTest(WasmOpcode simd_op, Int16BinOp expected_op) { 1042 void RunI16x8CompareOpTest(WasmOpcode simd_op, Int16BinOp expected_op) {
972 FLAG_wasm_simd_prototype = true; 1043 FLAG_wasm_simd_prototype = true;
973 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); 1044 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
974 byte a = 0; 1045 byte a = 0;
975 byte b = 1; 1046 byte b = 1;
976 byte expected = 2; 1047 byte expected = 2;
977 byte simd0 = r.AllocateLocal(kWasmS128); 1048 byte simd0 = r.AllocateLocal(kWasmS128);
978 byte simd1 = r.AllocateLocal(kWasmS128); 1049 byte simd1 = r.AllocateLocal(kWasmS128);
979 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), 1050 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))),
980 WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))), 1051 WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))),
981 WASM_SET_LOCAL(simd1, 1052 WASM_SET_LOCAL(simd1,
982 WASM_SIMD_MATERIALIZE_BOOLS( 1053 WASM_SIMD_MATERIALIZE_BOOLS(
983 16x8, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), 1054 16x8, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
984 WASM_GET_LOCAL(simd1)))), 1055 WASM_GET_LOCAL(simd1)))),
985 WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE); 1056 WASM_SIMD_CHECK_SPLAT8(I16x8, simd1, I32, expected), WASM_ONE);
986 1057
987 FOR_INT16_INPUTS(i) { 1058 FOR_INT16_INPUTS(i) {
988 FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } 1059 FOR_INT16_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); }
989 } 1060 }
990 } 1061 }
991 1062
992 WASM_EXEC_TEST(I16x8Equal) { RunI16x8CompareOpTest(kExprI16x8Eq, Equal); } 1063 WASM_EXEC_COMPILED_TEST(I16x8Equal) {
1064 RunI16x8CompareOpTest(kExprI16x8Eq, Equal);
1065 }
993 1066
994 WASM_EXEC_TEST(I16x8NotEqual) { RunI16x8CompareOpTest(kExprI16x8Ne, NotEqual); } 1067 WASM_EXEC_COMPILED_TEST(I16x8NotEqual) {
1068 RunI16x8CompareOpTest(kExprI16x8Ne, NotEqual);
1069 }
995 1070
996 WASM_EXEC_TEST(I16x8Greater) { RunI16x8CompareOpTest(kExprI16x8GtS, Greater); } 1071 WASM_EXEC_COMPILED_TEST(I16x8Greater) {
1072 RunI16x8CompareOpTest(kExprI16x8GtS, Greater);
1073 }
997 1074
998 WASM_EXEC_TEST(I16x8GreaterEqual) { 1075 WASM_EXEC_COMPILED_TEST(I16x8GreaterEqual) {
999 RunI16x8CompareOpTest(kExprI16x8GeS, GreaterEqual); 1076 RunI16x8CompareOpTest(kExprI16x8GeS, GreaterEqual);
1000 } 1077 }
1001 1078
1002 WASM_EXEC_TEST(I16x8Less) { RunI16x8CompareOpTest(kExprI16x8LtS, Less); } 1079 WASM_EXEC_COMPILED_TEST(I16x8Less) {
1080 RunI16x8CompareOpTest(kExprI16x8LtS, Less);
1081 }
1003 1082
1004 WASM_EXEC_TEST(I16x8LessEqual) { 1083 WASM_EXEC_COMPILED_TEST(I16x8LessEqual) {
1005 RunI16x8CompareOpTest(kExprI16x8LeS, LessEqual); 1084 RunI16x8CompareOpTest(kExprI16x8LeS, LessEqual);
1006 } 1085 }
1007 1086
1008 WASM_EXEC_TEST(Ui16x8Greater) { 1087 WASM_EXEC_COMPILED_TEST(Ui16x8Greater) {
1009 RunI16x8CompareOpTest(kExprI16x8GtU, UnsignedGreater); 1088 RunI16x8CompareOpTest(kExprI16x8GtU, UnsignedGreater);
1010 } 1089 }
1011 1090
1012 WASM_EXEC_TEST(Ui16x8GreaterEqual) { 1091 WASM_EXEC_COMPILED_TEST(Ui16x8GreaterEqual) {
1013 RunI16x8CompareOpTest(kExprI16x8GeU, UnsignedGreaterEqual); 1092 RunI16x8CompareOpTest(kExprI16x8GeU, UnsignedGreaterEqual);
1014 } 1093 }
1015 1094
1016 WASM_EXEC_TEST(Ui16x8Less) { 1095 WASM_EXEC_COMPILED_TEST(Ui16x8Less) {
1017 RunI16x8CompareOpTest(kExprI16x8LtU, UnsignedLess); 1096 RunI16x8CompareOpTest(kExprI16x8LtU, UnsignedLess);
1018 } 1097 }
1019 1098
1020 WASM_EXEC_TEST(Ui16x8LessEqual) { 1099 WASM_EXEC_COMPILED_TEST(Ui16x8LessEqual) {
1021 RunI16x8CompareOpTest(kExprI16x8LeU, UnsignedLessEqual); 1100 RunI16x8CompareOpTest(kExprI16x8LeU, UnsignedLessEqual);
1022 } 1101 }
1023 1102
1024 void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op, 1103 void RunI16x8ShiftOpTest(WasmOpcode simd_op, Int16ShiftOp expected_op,
1025 int shift) { 1104 int shift) {
1026 FLAG_wasm_simd_prototype = true; 1105 FLAG_wasm_simd_prototype = true;
1027 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 1106 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
1028 byte a = 0; 1107 byte a = 0;
1029 byte expected = 1; 1108 byte expected = 1;
1030 byte simd = r.AllocateLocal(kWasmS128); 1109 byte simd = r.AllocateLocal(kWasmS128);
1031 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), 1110 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))),
1032 WASM_SET_LOCAL( 1111 WASM_SET_LOCAL(
1033 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), 1112 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))),
1034 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE); 1113 WASM_SIMD_CHECK_SPLAT8(I16x8, simd, I32, expected), WASM_ONE);
1035 1114
1036 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } 1115 FOR_INT16_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); }
1037 } 1116 }
1038 1117
1039 WASM_EXEC_TEST(I16x8Shl) { 1118 WASM_EXEC_COMPILED_TEST(I16x8Shl) {
1040 RunI16x8ShiftOpTest(kExprI16x8Shl, LogicalShiftLeft, 1); 1119 RunI16x8ShiftOpTest(kExprI16x8Shl, LogicalShiftLeft, 1);
1041 } 1120 }
1042 1121
1043 WASM_EXEC_TEST(I16x8ShrS) { 1122 WASM_EXEC_COMPILED_TEST(I16x8ShrS) {
1044 RunI16x8ShiftOpTest(kExprI16x8ShrS, ArithmeticShiftRight, 1); 1123 RunI16x8ShiftOpTest(kExprI16x8ShrS, ArithmeticShiftRight, 1);
1045 } 1124 }
1046 1125
1047 WASM_EXEC_TEST(I16x8ShrU) { 1126 WASM_EXEC_COMPILED_TEST(I16x8ShrU) {
1048 RunI16x8ShiftOpTest(kExprI16x8ShrU, LogicalShiftRight, 1); 1127 RunI16x8ShiftOpTest(kExprI16x8ShrU, LogicalShiftRight, 1);
1049 } 1128 }
1050 1129
1051 void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) { 1130 void RunI8x16UnOpTest(WasmOpcode simd_op, Int8UnOp expected_op) {
1052 FLAG_wasm_simd_prototype = true; 1131 FLAG_wasm_simd_prototype = true;
1053 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 1132 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
1054 byte a = 0; 1133 byte a = 0;
1055 byte expected = 1; 1134 byte expected = 1;
1056 byte simd = r.AllocateLocal(kWasmS128); 1135 byte simd = r.AllocateLocal(kWasmS128);
1057 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), 1136 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))),
1058 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))), 1137 WASM_SET_LOCAL(simd, WASM_SIMD_UNOP(simd_op, WASM_GET_LOCAL(simd))),
1059 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE); 1138 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE);
1060 1139
1061 FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); } 1140 FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i))); }
1062 } 1141 }
1063 1142
1064 WASM_EXEC_TEST(I8x16Neg) { RunI8x16UnOpTest(kExprI8x16Neg, Negate); } 1143 WASM_EXEC_COMPILED_TEST(I8x16Neg) { RunI8x16UnOpTest(kExprI8x16Neg, Negate); }
1065 1144
1066 void RunI8x16BinOpTest(WasmOpcode simd_op, Int8BinOp expected_op) { 1145 void RunI8x16BinOpTest(WasmOpcode simd_op, Int8BinOp expected_op) {
1067 FLAG_wasm_simd_prototype = true; 1146 FLAG_wasm_simd_prototype = true;
1068 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); 1147 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
1069 byte a = 0; 1148 byte a = 0;
1070 byte b = 1; 1149 byte b = 1;
1071 byte expected = 2; 1150 byte expected = 2;
1072 byte simd0 = r.AllocateLocal(kWasmS128); 1151 byte simd0 = r.AllocateLocal(kWasmS128);
1073 byte simd1 = r.AllocateLocal(kWasmS128); 1152 byte simd1 = r.AllocateLocal(kWasmS128);
1074 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), 1153 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))),
1075 WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))), 1154 WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))),
1076 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), 1155 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
1077 WASM_GET_LOCAL(simd1))), 1156 WASM_GET_LOCAL(simd1))),
1078 WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE); 1157 WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE);
1079 1158
1080 FOR_INT8_INPUTS(i) { 1159 FOR_INT8_INPUTS(i) {
1081 FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } 1160 FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); }
1082 } 1161 }
1083 } 1162 }
1084 1163
1085 WASM_EXEC_TEST(I8x16Add) { RunI8x16BinOpTest(kExprI8x16Add, Add); } 1164 WASM_EXEC_COMPILED_TEST(I8x16Add) { RunI8x16BinOpTest(kExprI8x16Add, Add); }
1086 1165
1087 WASM_EXEC_TEST(I8x16AddSaturate) { 1166 WASM_EXEC_COMPILED_TEST(I8x16AddSaturate) {
1088 RunI8x16BinOpTest(kExprI8x16AddSaturateS, AddSaturate); 1167 RunI8x16BinOpTest(kExprI8x16AddSaturateS, AddSaturate);
1089 } 1168 }
1090 1169
1091 WASM_EXEC_TEST(I8x16Sub) { RunI8x16BinOpTest(kExprI8x16Sub, Sub); } 1170 WASM_EXEC_COMPILED_TEST(I8x16Sub) { RunI8x16BinOpTest(kExprI8x16Sub, Sub); }
1092 1171
1093 WASM_EXEC_TEST(I8x16SubSaturate) { 1172 WASM_EXEC_COMPILED_TEST(I8x16SubSaturate) {
1094 RunI8x16BinOpTest(kExprI8x16SubSaturateS, SubSaturate); 1173 RunI8x16BinOpTest(kExprI8x16SubSaturateS, SubSaturate);
1095 } 1174 }
1096 1175
1097 WASM_EXEC_TEST(I8x16Mul) { RunI8x16BinOpTest(kExprI8x16Mul, Mul); } 1176 WASM_EXEC_COMPILED_TEST(I8x16Mul) { RunI8x16BinOpTest(kExprI8x16Mul, Mul); }
1098 1177
1099 WASM_EXEC_TEST(I8x16Min) { RunI8x16BinOpTest(kExprI8x16MinS, Minimum); } 1178 WASM_EXEC_COMPILED_TEST(I8x16Min) {
1179 RunI8x16BinOpTest(kExprI8x16MinS, Minimum);
1180 }
1100 1181
1101 WASM_EXEC_TEST(I8x16Max) { RunI8x16BinOpTest(kExprI8x16MaxS, Maximum); } 1182 WASM_EXEC_COMPILED_TEST(I8x16Max) {
1183 RunI8x16BinOpTest(kExprI8x16MaxS, Maximum);
1184 }
1102 1185
1103 WASM_EXEC_TEST(Ui8x16AddSaturate) { 1186 WASM_EXEC_COMPILED_TEST(Ui8x16AddSaturate) {
1104 RunI8x16BinOpTest(kExprI8x16AddSaturateU, UnsignedAddSaturate); 1187 RunI8x16BinOpTest(kExprI8x16AddSaturateU, UnsignedAddSaturate);
1105 } 1188 }
1106 1189
1107 WASM_EXEC_TEST(Ui8x16SubSaturate) { 1190 WASM_EXEC_COMPILED_TEST(Ui8x16SubSaturate) {
1108 RunI8x16BinOpTest(kExprI8x16SubSaturateU, UnsignedSubSaturate); 1191 RunI8x16BinOpTest(kExprI8x16SubSaturateU, UnsignedSubSaturate);
1109 } 1192 }
1110 1193
1111 WASM_EXEC_TEST(Ui8x16Min) { 1194 WASM_EXEC_COMPILED_TEST(Ui8x16Min) {
1112 RunI8x16BinOpTest(kExprI8x16MinU, UnsignedMinimum); 1195 RunI8x16BinOpTest(kExprI8x16MinU, UnsignedMinimum);
1113 } 1196 }
1114 1197
1115 WASM_EXEC_TEST(Ui8x16Max) { 1198 WASM_EXEC_COMPILED_TEST(Ui8x16Max) {
1116 RunI8x16BinOpTest(kExprI8x16MaxU, UnsignedMaximum); 1199 RunI8x16BinOpTest(kExprI8x16MaxU, UnsignedMaximum);
1117 } 1200 }
1118 1201
1119 void RunI8x16CompareOpTest(WasmOpcode simd_op, Int8BinOp expected_op) { 1202 void RunI8x16CompareOpTest(WasmOpcode simd_op, Int8BinOp expected_op) {
1120 FLAG_wasm_simd_prototype = true; 1203 FLAG_wasm_simd_prototype = true;
1121 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); 1204 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
1122 byte a = 0; 1205 byte a = 0;
1123 byte b = 1; 1206 byte b = 1;
1124 byte expected = 2; 1207 byte expected = 2;
1125 byte simd0 = r.AllocateLocal(kWasmS128); 1208 byte simd0 = r.AllocateLocal(kWasmS128);
1126 byte simd1 = r.AllocateLocal(kWasmS128); 1209 byte simd1 = r.AllocateLocal(kWasmS128);
1127 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), 1210 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))),
1128 WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))), 1211 WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))),
1129 WASM_SET_LOCAL(simd1, 1212 WASM_SET_LOCAL(simd1,
1130 WASM_SIMD_MATERIALIZE_BOOLS( 1213 WASM_SIMD_MATERIALIZE_BOOLS(
1131 8x16, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0), 1214 8x16, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
1132 WASM_GET_LOCAL(simd1)))), 1215 WASM_GET_LOCAL(simd1)))),
1133 WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE); 1216 WASM_SIMD_CHECK_SPLAT16(I8x16, simd1, I32, expected), WASM_ONE);
1134 1217
1135 FOR_INT8_INPUTS(i) { 1218 FOR_INT8_INPUTS(i) {
1136 FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); } 1219 FOR_INT8_INPUTS(j) { CHECK_EQ(1, r.Call(*i, *j, expected_op(*i, *j))); }
1137 } 1220 }
1138 } 1221 }
1139 1222
1140 WASM_EXEC_TEST(I8x16Equal) { RunI8x16CompareOpTest(kExprI8x16Eq, Equal); } 1223 WASM_EXEC_COMPILED_TEST(I8x16Equal) {
1224 RunI8x16CompareOpTest(kExprI8x16Eq, Equal);
1225 }
1141 1226
1142 WASM_EXEC_TEST(I8x16NotEqual) { RunI8x16CompareOpTest(kExprI8x16Ne, NotEqual); } 1227 WASM_EXEC_COMPILED_TEST(I8x16NotEqual) {
1228 RunI8x16CompareOpTest(kExprI8x16Ne, NotEqual);
1229 }
1143 1230
1144 WASM_EXEC_TEST(I8x16Greater) { RunI8x16CompareOpTest(kExprI8x16GtS, Greater); } 1231 WASM_EXEC_COMPILED_TEST(I8x16Greater) {
1232 RunI8x16CompareOpTest(kExprI8x16GtS, Greater);
1233 }
1145 1234
1146 WASM_EXEC_TEST(I8x16GreaterEqual) { 1235 WASM_EXEC_COMPILED_TEST(I8x16GreaterEqual) {
1147 RunI8x16CompareOpTest(kExprI8x16GeS, GreaterEqual); 1236 RunI8x16CompareOpTest(kExprI8x16GeS, GreaterEqual);
1148 } 1237 }
1149 1238
1150 WASM_EXEC_TEST(I8x16Less) { RunI8x16CompareOpTest(kExprI8x16LtS, Less); } 1239 WASM_EXEC_COMPILED_TEST(I8x16Less) {
1240 RunI8x16CompareOpTest(kExprI8x16LtS, Less);
1241 }
1151 1242
1152 WASM_EXEC_TEST(I8x16LessEqual) { 1243 WASM_EXEC_COMPILED_TEST(I8x16LessEqual) {
1153 RunI8x16CompareOpTest(kExprI8x16LeS, LessEqual); 1244 RunI8x16CompareOpTest(kExprI8x16LeS, LessEqual);
1154 } 1245 }
1155 1246
1156 WASM_EXEC_TEST(Ui8x16Greater) { 1247 WASM_EXEC_COMPILED_TEST(Ui8x16Greater) {
1157 RunI8x16CompareOpTest(kExprI8x16GtU, UnsignedGreater); 1248 RunI8x16CompareOpTest(kExprI8x16GtU, UnsignedGreater);
1158 } 1249 }
1159 1250
1160 WASM_EXEC_TEST(Ui8x16GreaterEqual) { 1251 WASM_EXEC_COMPILED_TEST(Ui8x16GreaterEqual) {
1161 RunI8x16CompareOpTest(kExprI8x16GeU, UnsignedGreaterEqual); 1252 RunI8x16CompareOpTest(kExprI8x16GeU, UnsignedGreaterEqual);
1162 } 1253 }
1163 1254
1164 WASM_EXEC_TEST(Ui8x16Less) { 1255 WASM_EXEC_COMPILED_TEST(Ui8x16Less) {
1165 RunI8x16CompareOpTest(kExprI8x16LtU, UnsignedLess); 1256 RunI8x16CompareOpTest(kExprI8x16LtU, UnsignedLess);
1166 } 1257 }
1167 1258
1168 WASM_EXEC_TEST(Ui8x16LessEqual) { 1259 WASM_EXEC_COMPILED_TEST(Ui8x16LessEqual) {
1169 RunI8x16CompareOpTest(kExprI8x16LeU, UnsignedLessEqual); 1260 RunI8x16CompareOpTest(kExprI8x16LeU, UnsignedLessEqual);
1170 } 1261 }
1171 1262
1172 void RunI8x16ShiftOpTest(WasmOpcode simd_op, Int8ShiftOp expected_op, 1263 void RunI8x16ShiftOpTest(WasmOpcode simd_op, Int8ShiftOp expected_op,
1173 int shift) { 1264 int shift) {
1174 FLAG_wasm_simd_prototype = true; 1265 FLAG_wasm_simd_prototype = true;
1175 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); 1266 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled);
1176 byte a = 0; 1267 byte a = 0;
1177 byte expected = 1; 1268 byte expected = 1;
1178 byte simd = r.AllocateLocal(kWasmS128); 1269 byte simd = r.AllocateLocal(kWasmS128);
1179 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), 1270 BUILD(r, WASM_SET_LOCAL(simd, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))),
1180 WASM_SET_LOCAL( 1271 WASM_SET_LOCAL(
1181 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))), 1272 simd, WASM_SIMD_SHIFT_OP(simd_op, shift, WASM_GET_LOCAL(simd))),
1182 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE); 1273 WASM_SIMD_CHECK_SPLAT16(I8x16, simd, I32, expected), WASM_ONE);
1183 1274
1184 FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); } 1275 FOR_INT8_INPUTS(i) { CHECK_EQ(1, r.Call(*i, expected_op(*i, shift))); }
1185 } 1276 }
1186 1277
1187 WASM_EXEC_TEST(I8x16Shl) { 1278 WASM_EXEC_COMPILED_TEST(I8x16Shl) {
1188 RunI8x16ShiftOpTest(kExprI8x16Shl, LogicalShiftLeft, 1); 1279 RunI8x16ShiftOpTest(kExprI8x16Shl, LogicalShiftLeft, 1);
1189 } 1280 }
1190 1281
1191 WASM_EXEC_TEST(I8x16ShrS) { 1282 WASM_EXEC_COMPILED_TEST(I8x16ShrS) {
1192 RunI8x16ShiftOpTest(kExprI8x16ShrS, ArithmeticShiftRight, 1); 1283 RunI8x16ShiftOpTest(kExprI8x16ShrS, ArithmeticShiftRight, 1);
1193 } 1284 }
1194 1285
1195 WASM_EXEC_TEST(I8x16ShrU) { 1286 WASM_EXEC_COMPILED_TEST(I8x16ShrU) {
1196 RunI8x16ShiftOpTest(kExprI8x16ShrU, LogicalShiftRight, 1); 1287 RunI8x16ShiftOpTest(kExprI8x16ShrU, LogicalShiftRight, 1);
1197 } 1288 }
1198 1289
1199 // Test Select by making a mask where the first two lanes are true and the rest 1290 // Test Select by making a mask where the first two lanes are true and the rest
1200 // false, and comparing for non-equality with zero to materialize a bool vector. 1291 // false, and comparing for non-equality with zero to materialize a bool vector.
1201 #define WASM_SIMD_SELECT_TEST(format) \ 1292 #define WASM_SIMD_SELECT_TEST(format) \
1202 WASM_EXEC_TEST(S##format##Select) { \ 1293 WASM_EXEC_COMPILED_TEST(S##format##Select) { \
1203 FLAG_wasm_simd_prototype = true; \ 1294 FLAG_wasm_simd_prototype = true; \
1204 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); \ 1295 WasmRunner<int32_t, int32_t, int32_t> r(kExecuteCompiled); \
1205 byte val1 = 0; \ 1296 byte val1 = 0; \
1206 byte val2 = 1; \ 1297 byte val2 = 1; \
1207 byte src1 = r.AllocateLocal(kWasmS128); \ 1298 byte src1 = r.AllocateLocal(kWasmS128); \
1208 byte src2 = r.AllocateLocal(kWasmS128); \ 1299 byte src2 = r.AllocateLocal(kWasmS128); \
1209 byte zero = r.AllocateLocal(kWasmS128); \ 1300 byte zero = r.AllocateLocal(kWasmS128); \
1210 byte mask = r.AllocateLocal(kWasmS128); \ 1301 byte mask = r.AllocateLocal(kWasmS128); \
1211 BUILD(r, WASM_SET_LOCAL( \ 1302 BUILD(r, WASM_SET_LOCAL( \
1212 src1, WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val1))), \ 1303 src1, WASM_SIMD_I##format##_SPLAT(WASM_GET_LOCAL(val1))), \
(...skipping 15 matching lines...) Expand all
1228 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 2), \ 1319 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val1, 2), \
1229 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 3), WASM_ONE); \ 1320 WASM_SIMD_CHECK_LANE(I##format, mask, I32, val2, 3), WASM_ONE); \
1230 \ 1321 \
1231 CHECK_EQ(1, r.Call(0x12, 0x34)); \ 1322 CHECK_EQ(1, r.Call(0x12, 0x34)); \
1232 } 1323 }
1233 1324
1234 WASM_SIMD_SELECT_TEST(32x4) 1325 WASM_SIMD_SELECT_TEST(32x4)
1235 WASM_SIMD_SELECT_TEST(16x8) 1326 WASM_SIMD_SELECT_TEST(16x8)
1236 WASM_SIMD_SELECT_TEST(8x16) 1327 WASM_SIMD_SELECT_TEST(8x16)
1237 #endif // V8_TARGET_ARCH_ARM 1328 #endif // V8_TARGET_ARCH_ARM
1329
1330 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
1331 WASM_EXEC_COMPILED_TEST(SimdI32x4ExtractWithF32x4) {
1332 FLAG_wasm_simd_prototype = true;
1333 WasmRunner<int32_t> r(kExecuteCompiled);
1334 BUILD(r, WASM_IF_ELSE_I(
1335 WASM_I32_EQ(WASM_SIMD_I32x4_EXTRACT_LANE(
1336 0, WASM_SIMD_F32x4_SPLAT(WASM_F32(30.5))),
1337 WASM_I32_REINTERPRET_F32(WASM_F32(30.5))),
1338 WASM_I32V(1), WASM_I32V(0)));
1339 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
1340 }
1341
1342 WASM_EXEC_COMPILED_TEST(SimdF32x4ExtractWithI32x4) {
1343 FLAG_wasm_simd_prototype = true;
1344 WasmRunner<int32_t> r(kExecuteCompiled);
1345 BUILD(r,
1346 WASM_IF_ELSE_I(WASM_F32_EQ(WASM_SIMD_F32x4_EXTRACT_LANE(
1347 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(15))),
1348 WASM_F32_REINTERPRET_I32(WASM_I32V(15))),
1349 WASM_I32V(1), WASM_I32V(0)));
1350 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
1351 }
1352
1353 WASM_EXEC_COMPILED_TEST(SimdF32x4AddWithI32x4) {
1354 FLAG_wasm_simd_prototype = true;
1355 WasmRunner<int32_t> r(kExecuteCompiled);
1356 BUILD(r,
1357 WASM_IF_ELSE_I(
1358 WASM_F32_EQ(
1359 WASM_SIMD_F32x4_EXTRACT_LANE(
1360 0, WASM_SIMD_BINOP(kExprF32x4Add,
1361 WASM_SIMD_I32x4_SPLAT(WASM_I32V(32)),
1362 WASM_SIMD_I32x4_SPLAT(WASM_I32V(19)))),
1363 WASM_F32_ADD(WASM_F32_REINTERPRET_I32(WASM_I32V(32)),
1364 WASM_F32_REINTERPRET_I32(WASM_I32V(19)))),
1365 WASM_I32V(1), WASM_I32V(0)));
1366 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
1367 }
1368
1369 WASM_EXEC_COMPILED_TEST(SimdI32x4AddWithF32x4) {
1370 FLAG_wasm_simd_prototype = true;
1371 WasmRunner<int32_t> r(kExecuteCompiled);
1372 BUILD(r,
1373 WASM_IF_ELSE_I(
1374 WASM_I32_EQ(
1375 WASM_SIMD_I32x4_EXTRACT_LANE(
1376 0, WASM_SIMD_BINOP(kExprI32x4Add,
1377 WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25)),
1378 WASM_SIMD_F32x4_SPLAT(WASM_F32(31.5)))),
1379 WASM_I32_ADD(WASM_I32_REINTERPRET_F32(WASM_F32(21.25)),
1380 WASM_I32_REINTERPRET_F32(WASM_F32(31.5)))),
1381 WASM_I32V(1), WASM_I32V(0)));
1382 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
1383 }
1384
1385 WASM_EXEC_COMPILED_TEST(SimdI32x4Local) {
1386 FLAG_wasm_simd_prototype = true;
1387 WasmRunner<int32_t> r(kExecuteCompiled);
1388 r.AllocateLocal(kWasmS128);
1389 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
1390
1391 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(0)));
1392 FOR_INT32_INPUTS(i) { CHECK_EQ(31, r.Call()); }
1393 }
1394
1395 WASM_EXEC_COMPILED_TEST(SimdI32x4SplatFromExtract) {
1396 FLAG_wasm_simd_prototype = true;
1397 WasmRunner<int32_t> r(kExecuteCompiled);
1398 r.AllocateLocal(kWasmI32);
1399 r.AllocateLocal(kWasmS128);
1400 BUILD(r, WASM_SET_LOCAL(0, WASM_SIMD_I32x4_EXTRACT_LANE(
1401 0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(76)))),
1402 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(0))),
1403 WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(1)));
1404 FOR_INT32_INPUTS(i) { CHECK_EQ(76, r.Call()); }
1405 }
1406
1407 WASM_EXEC_COMPILED_TEST(SimdI32x4For) {
1408 FLAG_wasm_simd_prototype = true;
1409 WasmRunner<int32_t> r(kExecuteCompiled);
1410 r.AllocateLocal(kWasmI32);
1411 r.AllocateLocal(kWasmS128);
1412 BUILD(r,
1413
1414 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_SPLAT(WASM_I32V(31))),
1415 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_LOCAL(1),
1416 WASM_I32V(53))),
1417 WASM_SET_LOCAL(1, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_LOCAL(1),
1418 WASM_I32V(23))),
1419 WASM_SET_LOCAL(0, WASM_I32V(0)),
1420 WASM_LOOP(
1421 WASM_SET_LOCAL(
1422 1, WASM_SIMD_BINOP(kExprI32x4Add, WASM_GET_LOCAL(1),
1423 WASM_SIMD_I32x4_SPLAT(WASM_I32V(1)))),
1424 WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(0), WASM_I32V(5)), WASM_BR(1))),
1425 WASM_SET_LOCAL(0, WASM_I32V(1)),
1426 WASM_IF(WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(1)),
1427 WASM_I32V(36)),
1428 WASM_SET_LOCAL(0, WASM_I32V(0))),
1429 WASM_IF(WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_LOCAL(1)),
1430 WASM_I32V(58)),
1431 WASM_SET_LOCAL(0, WASM_I32V(0))),
1432 WASM_IF(WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_LOCAL(1)),
1433 WASM_I32V(28)),
1434 WASM_SET_LOCAL(0, WASM_I32V(0))),
1435 WASM_IF(WASM_I32_NE(WASM_SIMD_I32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1)),
1436 WASM_I32V(36)),
1437 WASM_SET_LOCAL(0, WASM_I32V(0))),
1438 WASM_GET_LOCAL(0));
1439 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
1440 }
1441
1442 WASM_EXEC_COMPILED_TEST(SimdF32x4For) {
1443 FLAG_wasm_simd_prototype = true;
1444 WasmRunner<int32_t> r(kExecuteCompiled);
1445 r.AllocateLocal(kWasmI32);
1446 r.AllocateLocal(kWasmS128);
1447 BUILD(r, WASM_SET_LOCAL(1, WASM_SIMD_F32x4_SPLAT(WASM_F32(21.25))),
1448 WASM_SET_LOCAL(1, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_LOCAL(1),
1449 WASM_F32(19.5))),
1450 WASM_SET_LOCAL(0, WASM_I32V(0)),
1451 WASM_LOOP(
1452 WASM_SET_LOCAL(
1453 1, WASM_SIMD_BINOP(kExprF32x4Add, WASM_GET_LOCAL(1),
1454 WASM_SIMD_F32x4_SPLAT(WASM_F32(2.0)))),
1455 WASM_IF(WASM_I32_NE(WASM_INC_LOCAL(0), WASM_I32V(3)), WASM_BR(1))),
1456 WASM_SET_LOCAL(0, WASM_I32V(1)),
1457 WASM_IF(WASM_F32_NE(WASM_SIMD_F32x4_EXTRACT_LANE(0, WASM_GET_LOCAL(1)),
1458 WASM_F32(27.25)),
1459 WASM_SET_LOCAL(0, WASM_I32V(0))),
1460 WASM_IF(WASM_F32_NE(WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_LOCAL(1)),
1461 WASM_F32(25.5)),
1462 WASM_SET_LOCAL(0, WASM_I32V(0))),
1463 WASM_GET_LOCAL(0));
1464 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call()); }
1465 }
1466 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
1467
1468 #if SIMD_LOWERING_TARGET
1469 WASM_EXEC_COMPILED_TEST(SimdI32x4GetGlobal) {
1470 FLAG_wasm_simd_prototype = true;
1471 WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
1472 int32_t* global = r.module().AddGlobal<int32_t>(kWasmS128);
1473 *(global) = 0;
1474 *(global + 1) = 1;
1475 *(global + 2) = 2;
1476 *(global + 3) = 3;
1477 r.AllocateLocal(kWasmI32);
1478 BUILD(
1479 r, WASM_SET_LOCAL(1, WASM_I32V(1)),
1480 WASM_IF(WASM_I32_NE(WASM_I32V(0),
1481 WASM_SIMD_I32x4_EXTRACT_LANE(0, WASM_GET_GLOBAL(0))),
1482 WASM_SET_LOCAL(1, WASM_I32V(0))),
1483 WASM_IF(WASM_I32_NE(WASM_I32V(1),
1484 WASM_SIMD_I32x4_EXTRACT_LANE(1, WASM_GET_GLOBAL(0))),
1485 WASM_SET_LOCAL(1, WASM_I32V(0))),
1486 WASM_IF(WASM_I32_NE(WASM_I32V(2),
1487 WASM_SIMD_I32x4_EXTRACT_LANE(2, WASM_GET_GLOBAL(0))),
1488 WASM_SET_LOCAL(1, WASM_I32V(0))),
1489 WASM_IF(WASM_I32_NE(WASM_I32V(3),
1490 WASM_SIMD_I32x4_EXTRACT_LANE(3, WASM_GET_GLOBAL(0))),
1491 WASM_SET_LOCAL(1, WASM_I32V(0))),
1492 WASM_GET_LOCAL(1));
1493 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); }
1494 }
1495
1496 WASM_EXEC_COMPILED_TEST(SimdI32x4SetGlobal) {
1497 FLAG_wasm_simd_prototype = true;
1498 WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
1499 int32_t* global = r.module().AddGlobal<int32_t>(kWasmS128);
1500 BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_SPLAT(WASM_I32V(23))),
1501 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0),
1502 WASM_I32V(34))),
1503 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(2, WASM_GET_GLOBAL(0),
1504 WASM_I32V(45))),
1505 WASM_SET_GLOBAL(0, WASM_SIMD_I32x4_REPLACE_LANE(3, WASM_GET_GLOBAL(0),
1506 WASM_I32V(56))),
1507 WASM_I32V(1));
1508 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); }
1509 CHECK_EQ(*global, 23);
1510 CHECK_EQ(*(global + 1), 34);
1511 CHECK_EQ(*(global + 2), 45);
1512 CHECK_EQ(*(global + 3), 56);
1513 }
1514
1515 WASM_EXEC_COMPILED_TEST(SimdF32x4GetGlobal) {
1516 FLAG_wasm_simd_prototype = true;
1517 WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
1518 float* global = r.module().AddGlobal<float>(kWasmS128);
1519 *(global) = 0.0;
1520 *(global + 1) = 1.5;
1521 *(global + 2) = 2.25;
1522 *(global + 3) = 3.5;
1523 r.AllocateLocal(kWasmI32);
1524 BUILD(
1525 r, WASM_SET_LOCAL(1, WASM_I32V(1)),
1526 WASM_IF(WASM_F32_NE(WASM_F32(0.0),
1527 WASM_SIMD_F32x4_EXTRACT_LANE(0, WASM_GET_GLOBAL(0))),
1528 WASM_SET_LOCAL(1, WASM_I32V(0))),
1529 WASM_IF(WASM_F32_NE(WASM_F32(1.5),
1530 WASM_SIMD_F32x4_EXTRACT_LANE(1, WASM_GET_GLOBAL(0))),
1531 WASM_SET_LOCAL(1, WASM_I32V(0))),
1532 WASM_IF(WASM_F32_NE(WASM_F32(2.25),
1533 WASM_SIMD_F32x4_EXTRACT_LANE(2, WASM_GET_GLOBAL(0))),
1534 WASM_SET_LOCAL(1, WASM_I32V(0))),
1535 WASM_IF(WASM_F32_NE(WASM_F32(3.5),
1536 WASM_SIMD_F32x4_EXTRACT_LANE(3, WASM_GET_GLOBAL(0))),
1537 WASM_SET_LOCAL(1, WASM_I32V(0))),
1538 WASM_GET_LOCAL(1));
1539 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); }
1540 }
1541
1542 WASM_EXEC_COMPILED_TEST(SimdF32x4SetGlobal) {
1543 FLAG_wasm_simd_prototype = true;
1544 WasmRunner<int32_t, int32_t> r(kExecuteCompiled);
1545 float* global = r.module().AddGlobal<float>(kWasmS128);
1546 BUILD(r, WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_SPLAT(WASM_F32(13.5))),
1547 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(1, WASM_GET_GLOBAL(0),
1548 WASM_F32(45.5))),
1549 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(2, WASM_GET_GLOBAL(0),
1550 WASM_F32(32.25))),
1551 WASM_SET_GLOBAL(0, WASM_SIMD_F32x4_REPLACE_LANE(3, WASM_GET_GLOBAL(0),
1552 WASM_F32(65.0))),
1553 WASM_I32V(1));
1554 FOR_INT32_INPUTS(i) { CHECK_EQ(1, r.Call(0)); }
1555 CHECK_EQ(*global, 13.5);
1556 CHECK_EQ(*(global + 1), 45.5);
1557 CHECK_EQ(*(global + 2), 32.25);
1558 CHECK_EQ(*(global + 3), 65.0);
1559 }
1560 #endif // SIMD_LOWERING_TARGET
OLDNEW
« no previous file with comments | « test/cctest/cctest.gyp ('k') | test/cctest/wasm/test-run-wasm-simd-lowering.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698