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

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

Issue 2804883008: [WASM SIMD] Implement horizontal add for float and integer types. (Closed)
Patch Set: Fix MIPS. Created 3 years, 8 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
« src/wasm/wasm-opcodes.h ('K') | « test/cctest/test-disasm-arm.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/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 569 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 580 #if V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
581 WASM_EXEC_COMPILED_TEST(F32x4RecipRefine) { 581 WASM_EXEC_COMPILED_TEST(F32x4RecipRefine) {
582 RunF32x4BinOpTest(kExprF32x4RecipRefine, RecipRefine); 582 RunF32x4BinOpTest(kExprF32x4RecipRefine, RecipRefine);
583 } 583 }
584 584
585 WASM_EXEC_COMPILED_TEST(F32x4RecipSqrtRefine) { 585 WASM_EXEC_COMPILED_TEST(F32x4RecipSqrtRefine) {
586 RunF32x4BinOpTest(kExprF32x4RecipSqrtRefine, RecipSqrtRefine); 586 RunF32x4BinOpTest(kExprF32x4RecipSqrtRefine, RecipSqrtRefine);
587 } 587 }
588 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64 588 #endif // V8_TARGET_ARCH_ARM || V8_TARGET_ARCH_MIPS || V8_TARGET_ARCH_MIPS64
589 589
590 #if V8_TARGET_ARCH_ARM
591 void RunF32x4HorizOpTest(WasmOpcode simd_op, FloatBinOp expected_op) {
592 FLAG_wasm_simd_prototype = true;
593 WasmRunner<int32_t, float, float, float, float> r(kExecuteCompiled);
594 byte a = 0;
595 byte b = 1;
596 byte expected1 = 2;
597 byte expected2 = 3;
598 byte simd0 = r.AllocateLocal(kWasmS128);
599 byte simd1 = r.AllocateLocal(kWasmS128);
600 BUILD(
601 r, WASM_SET_LOCAL(simd0, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(a))),
602 WASM_SET_LOCAL(simd1, WASM_SIMD_F32x4_SPLAT(WASM_GET_LOCAL(b))),
603 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
604 WASM_GET_LOCAL(simd1))),
605 WASM_SIMD_CHECK_F32x4(simd1, expected1, expected1, expected2, expected2),
606 WASM_RETURN1(WASM_ONE));
607
608 FOR_FLOAT32_INPUTS(i) {
609 if (SkipFPValue(*i)) continue;
610 FOR_FLOAT32_INPUTS(j) {
611 if (SkipFPValue(*j)) continue;
612 float expected1 = expected_op(*i, *i);
613 float expected2 = expected_op(*j, *j);
614 if (SkipFPExpectedValue(expected1) || SkipFPExpectedValue(expected2))
615 continue;
616 CHECK_EQ(1, r.Call(*i, *j, expected1, expected2));
617 }
618 }
619 }
620
621 WASM_EXEC_COMPILED_TEST(F32x4AddHoriz) {
622 RunF32x4HorizOpTest(kExprF32x4AddHoriz, Add);
623 }
624 #endif // V8_TARGET_ARCH_ARM
625
590 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \ 626 #if V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET || V8_TARGET_ARCH_MIPS || \
591 V8_TARGET_ARCH_MIPS64 627 V8_TARGET_ARCH_MIPS64
592 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) { 628 void RunF32x4CompareOpTest(WasmOpcode simd_op, FloatCompareOp expected_op) {
593 FLAG_wasm_simd_prototype = true; 629 FLAG_wasm_simd_prototype = true;
594 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled); 630 WasmRunner<int32_t, float, float, int32_t> r(kExecuteCompiled);
595 byte a = 0; 631 byte a = 0;
596 byte b = 1; 632 byte b = 1;
597 byte expected = 2; 633 byte expected = 2;
598 byte simd0 = r.AllocateLocal(kWasmS128); 634 byte simd0 = r.AllocateLocal(kWasmS128);
599 byte simd1 = r.AllocateLocal(kWasmS128); 635 byte simd1 = r.AllocateLocal(kWasmS128);
(...skipping 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
1035 } 1071 }
1036 1072
1037 WASM_EXEC_COMPILED_TEST(I32x4MinU) { 1073 WASM_EXEC_COMPILED_TEST(I32x4MinU) {
1038 RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum); 1074 RunI32x4BinOpTest(kExprI32x4MinU, UnsignedMinimum);
1039 } 1075 }
1040 1076
1041 WASM_EXEC_COMPILED_TEST(I32x4MaxU) { 1077 WASM_EXEC_COMPILED_TEST(I32x4MaxU) {
1042 RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum); 1078 RunI32x4BinOpTest(kExprI32x4MaxU, UnsignedMaximum);
1043 } 1079 }
1044 1080
1081 #if V8_TARGET_ARCH_ARM
1082 void RunI32x4HorizOpTest(WasmOpcode simd_op, Int32BinOp expected_op) {
1083 FLAG_wasm_simd_prototype = true;
1084 WasmRunner<int32_t, int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
1085 byte a = 0;
1086 byte b = 1;
1087 byte expected1 = 2;
1088 byte expected2 = 3;
1089 byte simd0 = r.AllocateLocal(kWasmS128);
1090 byte simd1 = r.AllocateLocal(kWasmS128);
1091 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
1092 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))),
1093 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
1094 WASM_GET_LOCAL(simd1))),
1095 WASM_SIMD_CHECK4(I32x4, simd1, I32, expected1, expected1, expected2,
1096 expected2),
1097 WASM_RETURN1(WASM_ONE));
1098
1099 FOR_INT32_INPUTS(i) {
1100 FOR_INT32_INPUTS(j) {
1101 int32_t expected1 = expected_op(*i, *i);
1102 int32_t expected2 = expected_op(*j, *j);
1103 CHECK_EQ(1, r.Call(*i, *j, expected1, expected2));
1104 }
1105 }
1106 }
1107
1108 WASM_EXEC_COMPILED_TEST(I32x4AddHoriz) {
1109 RunI32x4HorizOpTest(kExprI32x4AddHoriz, Add);
1110 }
1111 #endif // V8_TARGET_ARCH_ARM
1112
1045 void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32CompareOp expected_op) { 1113 void RunI32x4CompareOpTest(WasmOpcode simd_op, Int32CompareOp expected_op) {
1046 FLAG_wasm_simd_prototype = true; 1114 FLAG_wasm_simd_prototype = true;
1047 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); 1115 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
1048 byte a = 0; 1116 byte a = 0;
1049 byte b = 1; 1117 byte b = 1;
1050 byte expected = 2; 1118 byte expected = 2;
1051 byte simd0 = r.AllocateLocal(kWasmS128); 1119 byte simd0 = r.AllocateLocal(kWasmS128);
1052 byte simd1 = r.AllocateLocal(kWasmS128); 1120 byte simd1 = r.AllocateLocal(kWasmS128);
1053 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))), 1121 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(a))),
1054 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))), 1122 WASM_SET_LOCAL(simd1, WASM_SIMD_I32x4_SPLAT(WASM_GET_LOCAL(b))),
(...skipping 203 matching lines...) Expand 10 before | Expand all | Expand 10 after
1258 } 1326 }
1259 1327
1260 WASM_EXEC_COMPILED_TEST(I16x8MinU) { 1328 WASM_EXEC_COMPILED_TEST(I16x8MinU) {
1261 RunI16x8BinOpTest(kExprI16x8MinU, UnsignedMinimum); 1329 RunI16x8BinOpTest(kExprI16x8MinU, UnsignedMinimum);
1262 } 1330 }
1263 1331
1264 WASM_EXEC_COMPILED_TEST(I16x8MaxU) { 1332 WASM_EXEC_COMPILED_TEST(I16x8MaxU) {
1265 RunI16x8BinOpTest(kExprI16x8MaxU, UnsignedMaximum); 1333 RunI16x8BinOpTest(kExprI16x8MaxU, UnsignedMaximum);
1266 } 1334 }
1267 1335
1336 #if V8_TARGET_ARCH_ARM
1337 void RunI16x8HorizOpTest(WasmOpcode simd_op, Int16BinOp expected_op) {
1338 FLAG_wasm_simd_prototype = true;
1339 WasmRunner<int32_t, int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
1340 byte a = 0;
1341 byte b = 1;
1342 byte expected1 = 2;
1343 byte expected2 = 3;
1344 byte simd0 = r.AllocateLocal(kWasmS128);
1345 byte simd1 = r.AllocateLocal(kWasmS128);
1346 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))),
1347 WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))),
1348 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
1349 WASM_GET_LOCAL(simd1))),
1350 WASM_SIMD_CHECK8(I16x8, simd1, I32, expected1, expected1, expected1,
1351 expected1, expected2, expected2, expected2, expected2),
1352 WASM_RETURN1(WASM_ONE));
1353
1354 FOR_INT16_INPUTS(i) {
1355 FOR_INT16_INPUTS(j) {
1356 int32_t expected1 = expected_op(*i, *i);
1357 int32_t expected2 = expected_op(*j, *j);
1358 CHECK_EQ(1, r.Call(*i, *j, expected1, expected2));
1359 }
1360 }
1361 }
1362
1363 WASM_EXEC_COMPILED_TEST(I16x8AddHoriz) {
1364 RunI16x8HorizOpTest(kExprI16x8AddHoriz, Add);
1365 }
1366 #endif // V8_TARGET_ARCH_ARM
1367
1268 void RunI16x8CompareOpTest(WasmOpcode simd_op, Int16CompareOp expected_op) { 1368 void RunI16x8CompareOpTest(WasmOpcode simd_op, Int16CompareOp expected_op) {
1269 FLAG_wasm_simd_prototype = true; 1369 FLAG_wasm_simd_prototype = true;
1270 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); 1370 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
1271 byte a = 0; 1371 byte a = 0;
1272 byte b = 1; 1372 byte b = 1;
1273 byte expected = 2; 1373 byte expected = 2;
1274 byte simd0 = r.AllocateLocal(kWasmS128); 1374 byte simd0 = r.AllocateLocal(kWasmS128);
1275 byte simd1 = r.AllocateLocal(kWasmS128); 1375 byte simd1 = r.AllocateLocal(kWasmS128);
1276 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))), 1376 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(a))),
1277 WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))), 1377 WASM_SET_LOCAL(simd1, WASM_SIMD_I16x8_SPLAT(WASM_GET_LOCAL(b))),
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
1451 } 1551 }
1452 1552
1453 WASM_EXEC_COMPILED_TEST(I8x16MinU) { 1553 WASM_EXEC_COMPILED_TEST(I8x16MinU) {
1454 RunI8x16BinOpTest(kExprI8x16MinU, UnsignedMinimum); 1554 RunI8x16BinOpTest(kExprI8x16MinU, UnsignedMinimum);
1455 } 1555 }
1456 1556
1457 WASM_EXEC_COMPILED_TEST(I8x16MaxU) { 1557 WASM_EXEC_COMPILED_TEST(I8x16MaxU) {
1458 RunI8x16BinOpTest(kExprI8x16MaxU, UnsignedMaximum); 1558 RunI8x16BinOpTest(kExprI8x16MaxU, UnsignedMaximum);
1459 } 1559 }
1460 1560
1561 #if V8_TARGET_ARCH_ARM
1562 void RunI8x16HorizOpTest(WasmOpcode simd_op, Int8BinOp expected_op) {
1563 FLAG_wasm_simd_prototype = true;
1564 WasmRunner<int32_t, int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
1565 byte a = 0;
1566 byte b = 1;
1567 byte expected1 = 2;
1568 byte expected2 = 3;
1569 byte simd0 = r.AllocateLocal(kWasmS128);
1570 byte simd1 = r.AllocateLocal(kWasmS128);
1571 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))),
1572 WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))),
1573 WASM_SET_LOCAL(simd1, WASM_SIMD_BINOP(simd_op, WASM_GET_LOCAL(simd0),
1574 WASM_GET_LOCAL(simd1))),
1575 WASM_SIMD_CHECK16(I8x16, simd1, I32, expected1, expected1, expected1,
1576 expected1, expected1, expected1, expected1, expected1,
1577 expected2, expected2, expected2, expected2, expected2,
1578 expected2, expected2, expected2),
1579 WASM_RETURN1(WASM_ONE));
1580
1581 FOR_INT8_INPUTS(i) {
1582 FOR_INT8_INPUTS(j) {
1583 int32_t expected1 = expected_op(*i, *i);
1584 int32_t expected2 = expected_op(*j, *j);
1585 CHECK_EQ(1, r.Call(*i, *j, expected1, expected2));
1586 }
1587 }
1588 }
1589
1590 WASM_EXEC_COMPILED_TEST(I8x16AddHoriz) {
1591 RunI8x16HorizOpTest(kExprI8x16AddHoriz, Add);
1592 }
1593 #endif // V8_TARGET_ARCH_ARM
1594
1461 void RunI8x16CompareOpTest(WasmOpcode simd_op, Int8CompareOp expected_op) { 1595 void RunI8x16CompareOpTest(WasmOpcode simd_op, Int8CompareOp expected_op) {
1462 FLAG_wasm_simd_prototype = true; 1596 FLAG_wasm_simd_prototype = true;
1463 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled); 1597 WasmRunner<int32_t, int32_t, int32_t, int32_t> r(kExecuteCompiled);
1464 byte a = 0; 1598 byte a = 0;
1465 byte b = 1; 1599 byte b = 1;
1466 byte expected = 2; 1600 byte expected = 2;
1467 byte simd0 = r.AllocateLocal(kWasmS128); 1601 byte simd0 = r.AllocateLocal(kWasmS128);
1468 byte simd1 = r.AllocateLocal(kWasmS128); 1602 byte simd1 = r.AllocateLocal(kWasmS128);
1469 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))), 1603 BUILD(r, WASM_SET_LOCAL(simd0, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(a))),
1470 WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))), 1604 WASM_SET_LOCAL(simd1, WASM_SIMD_I8x16_SPLAT(WASM_GET_LOCAL(b))),
(...skipping 751 matching lines...) Expand 10 before | Expand all | Expand 10 after
2222 WASM_SIMD_I32x4_EXTRACT_LANE( 2356 WASM_SIMD_I32x4_EXTRACT_LANE(
2223 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO))); 2357 0, WASM_LOAD_MEM(MachineType::Simd128(), WASM_ZERO)));
2224 2358
2225 FOR_INT32_INPUTS(i) { 2359 FOR_INT32_INPUTS(i) {
2226 int32_t expected = *i; 2360 int32_t expected = *i;
2227 r.module().WriteMemory(&memory[0], expected); 2361 r.module().WriteMemory(&memory[0], expected);
2228 CHECK_EQ(expected, r.Call()); 2362 CHECK_EQ(expected, r.Call());
2229 } 2363 }
2230 } 2364 }
2231 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET 2365 #endif // V8_TARGET_ARCH_ARM || SIMD_LOWERING_TARGET
OLDNEW
« src/wasm/wasm-opcodes.h ('K') | « test/cctest/test-disasm-arm.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698