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

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

Issue 1843123002: [wasm] Int64Lowering of Word64Ror and Word64Rol. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Better code is generated now. Created 4 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
« no previous file with comments | « test/cctest/compiler/value-helper.h ('k') | test/unittests/compiler/int64-lowering-unittest.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 2015 the V8 project authors. All rights reserved. 1 // Copyright 2015 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 <stdint.h> 5 #include <stdint.h>
6 #include <stdlib.h> 6 #include <stdlib.h>
7 #include <string.h> 7 #include <string.h>
8 8
9 #include "src/base/bits.h"
9 #include "src/wasm/wasm-macro-gen.h" 10 #include "src/wasm/wasm-macro-gen.h"
10 11
11 #include "test/cctest/cctest.h" 12 #include "test/cctest/cctest.h"
12 #include "test/cctest/compiler/value-helper.h" 13 #include "test/cctest/compiler/value-helper.h"
13 #include "test/cctest/wasm/test-signatures.h" 14 #include "test/cctest/wasm/test-signatures.h"
14 #include "test/cctest/wasm/wasm-run-utils.h" 15 #include "test/cctest/wasm/wasm-run-utils.h"
15 16
16 #define CHECK_TRAP32(x) \ 17 #define CHECK_TRAP32(x) \
17 CHECK_EQ(0xdeadbeef, (bit_cast<uint32_t>(x)) & 0xFFFFFFFF) 18 CHECK_EQ(0xdeadbeef, (bit_cast<uint32_t>(x)) & 0xFFFFFFFF)
18 #define CHECK_TRAP64(x) \ 19 #define CHECK_TRAP64(x) \
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
78 V(I64UConvertF32, true) \ 79 V(I64UConvertF32, true) \
79 V(I64UConvertF64, true) \ 80 V(I64UConvertF64, true) \
80 V(I64SConvertI32, true) \ 81 V(I64SConvertI32, true) \
81 V(I64UConvertI32, true) \ 82 V(I64UConvertI32, true) \
82 V(F32SConvertI64, true) \ 83 V(F32SConvertI64, true) \
83 V(F32UConvertI64, true) \ 84 V(F32UConvertI64, true) \
84 V(F64SConvertI64, true) \ 85 V(F64SConvertI64, true) \
85 V(F64UConvertI64, true) \ 86 V(F64UConvertI64, true) \
86 V(F64ReinterpretI64, true) \ 87 V(F64ReinterpretI64, true) \
87 V(I64ReinterpretF64, true) \ 88 V(I64ReinterpretF64, true) \
88 V(I64Ror, false) \ 89 V(I64Ror, true) \
89 V(I64Rol, false) 90 V(I64Rol, true)
90 91
91 #define DECLARE_CONST(name, cond) static const bool kSupported_##name = cond; 92 #define DECLARE_CONST(name, cond) static const bool kSupported_##name = cond;
92 FOREACH_I64_OPERATOR(DECLARE_CONST) 93 FOREACH_I64_OPERATOR(DECLARE_CONST)
93 #undef DECLARE_CONST 94 #undef DECLARE_CONST
94 95
95 #define REQUIRE(name) \ 96 #define REQUIRE(name) \
96 if (!WASM_64 && !kSupported_##name) return 97 if (!WASM_64 && !kSupported_##name) return
97 98
98 TEST(Run_Wasm_I64Const) { 99 TEST(Run_Wasm_I64Const) {
99 REQUIRE(I64Const); 100 REQUIRE(I64Const);
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
310 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); 311 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64());
311 BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 312 BUILD(r, WASM_I64_XOR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
312 FOR_INT64_INPUTS(i) { 313 FOR_INT64_INPUTS(i) {
313 FOR_INT64_INPUTS(j) { CHECK_EQ((*i) ^ (*j), r.Call(*i, *j)); } 314 FOR_INT64_INPUTS(j) { CHECK_EQ((*i) ^ (*j), r.Call(*i, *j)); }
314 } 315 }
315 } 316 }
316 // kExprI64Shl: 317 // kExprI64Shl:
317 TEST(Run_Wasm_I64Shl) { 318 TEST(Run_Wasm_I64Shl) {
318 REQUIRE(I64Shl); 319 REQUIRE(I64Shl);
319 { 320 {
320 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); 321 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64());
321 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 322 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
323
322 FOR_UINT64_INPUTS(i) { 324 FOR_UINT64_INPUTS(i) {
323 for (int64_t j = 1; j < 64; j++) { 325 FOR_UINT64_INPUTS(j) {
324 CHECK_EQ(*i << j, r.Call(*i, j)); 326 uint64_t expected = (*i) << (*j & 0x3f);
327 CHECK_EQ(expected, r.Call(*i, *j));
325 } 328 }
326 } 329 }
327 } 330 }
328 { 331 {
329 WasmRunner<int64_t> r(MachineType::Int64()); 332 WasmRunner<int64_t> r(MachineType::Int64());
330 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(0))); 333 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(0)));
331 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 0, r.Call(*i)); } 334 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 0, r.Call(*i)); }
332 } 335 }
333 { 336 {
334 WasmRunner<int64_t> r(MachineType::Int64()); 337 WasmRunner<int64_t> r(MachineType::Int64());
335 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(32))); 338 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(32)));
336 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 32, r.Call(*i)); } 339 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 32, r.Call(*i)); }
337 } 340 }
338 { 341 {
339 WasmRunner<int64_t> r(MachineType::Int64()); 342 WasmRunner<int64_t> r(MachineType::Int64());
340 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(20))); 343 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(20)));
341 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 20, r.Call(*i)); } 344 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 20, r.Call(*i)); }
342 } 345 }
343 { 346 {
344 WasmRunner<int64_t> r(MachineType::Int64()); 347 WasmRunner<int64_t> r(MachineType::Int64());
345 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(40))); 348 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_I64V_1(40)));
346 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 40, r.Call(*i)); } 349 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i << 40, r.Call(*i)); }
347 } 350 }
348 } 351 }
349 // kExprI64ShrU: 352 // kExprI64ShrU:
350 TEST(Run_Wasm_I64ShrU) { 353 TEST(Run_Wasm_I64ShrU) {
351 REQUIRE(I64ShrU); 354 REQUIRE(I64ShrU);
352 { 355 {
353 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); 356 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64());
354 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 357 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
358
355 FOR_UINT64_INPUTS(i) { 359 FOR_UINT64_INPUTS(i) {
356 for (int64_t j = 1; j < 64; j++) { 360 FOR_UINT64_INPUTS(j) {
357 CHECK_EQ(*i >> j, r.Call(*i, j)); 361 uint64_t expected = (*i) >> (*j & 0x3f);
362 CHECK_EQ(expected, r.Call(*i, *j));
358 } 363 }
359 } 364 }
360 } 365 }
361 { 366 {
362 WasmRunner<int64_t> r(MachineType::Int64()); 367 WasmRunner<int64_t> r(MachineType::Int64());
363 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(0))); 368 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(0)));
364 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 0, r.Call(*i)); } 369 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 0, r.Call(*i)); }
365 } 370 }
366 { 371 {
367 WasmRunner<int64_t> r(MachineType::Int64()); 372 WasmRunner<int64_t> r(MachineType::Int64());
(...skipping 10 matching lines...) Expand all
378 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(40))); 383 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_I64V_1(40)));
379 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 40, r.Call(*i)); } 384 FOR_UINT64_INPUTS(i) { CHECK_EQ(*i >> 40, r.Call(*i)); }
380 } 385 }
381 } 386 }
382 // kExprI64ShrS: 387 // kExprI64ShrS:
383 TEST(Run_Wasm_I64ShrS) { 388 TEST(Run_Wasm_I64ShrS) {
384 REQUIRE(I64ShrS); 389 REQUIRE(I64ShrS);
385 { 390 {
386 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64()); 391 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64());
387 BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 392 BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
393
388 FOR_INT64_INPUTS(i) { 394 FOR_INT64_INPUTS(i) {
389 for (int64_t j = 1; j < 64; j++) { 395 FOR_INT64_INPUTS(j) {
390 CHECK_EQ(*i >> j, r.Call(*i, j)); 396 int64_t expected = (*i) >> (*j & 0x3f);
397 CHECK_EQ(expected, r.Call(*i, *j));
391 } 398 }
392 } 399 }
393 } 400 }
394 { 401 {
395 WasmRunner<int64_t> r(MachineType::Int64()); 402 WasmRunner<int64_t> r(MachineType::Int64());
396 BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(0))); 403 BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_I64V_1(0)));
397 FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 0, r.Call(*i)); } 404 FOR_INT64_INPUTS(i) { CHECK_EQ(*i >> 0, r.Call(*i)); }
398 } 405 }
399 { 406 {
400 WasmRunner<int64_t> r(MachineType::Int64()); 407 WasmRunner<int64_t> r(MachineType::Int64());
(...skipping 906 matching lines...) Expand 10 before | Expand all | Expand 10 after
1307 WASM_ZERO)); 1314 WASM_ZERO));
1308 1315
1309 *global = 0xFFFFFFFFFFFFFFFFLL; 1316 *global = 0xFFFFFFFFFFFFFFFFLL;
1310 for (int i = 9; i < 444444; i += 111111) { 1317 for (int i = 9; i < 444444; i += 111111) {
1311 int64_t expected = *global & i; 1318 int64_t expected = *global & i;
1312 r.Call(i); 1319 r.Call(i);
1313 CHECK_EQ(expected, *global); 1320 CHECK_EQ(expected, *global);
1314 } 1321 }
1315 } 1322 }
1316 1323
1317 TEST(Run_WasmI64Eqz) { 1324 TEST(Run_Wasm_I64Eqz) {
1318 REQUIRE(I64Eq); 1325 REQUIRE(I64Eq);
1319 1326
1320 WasmRunner<int32_t> r(MachineType::Int64()); 1327 WasmRunner<int32_t> r(MachineType::Int64());
1321 BUILD(r, WASM_I64_EQZ(WASM_GET_LOCAL(0))); 1328 BUILD(r, WASM_I64_EQZ(WASM_GET_LOCAL(0)));
1322 1329
1323 FOR_INT64_INPUTS(i) { 1330 FOR_INT64_INPUTS(i) {
1324 int32_t result = *i == 0 ? 1 : 0; 1331 int32_t result = *i == 0 ? 1 : 0;
1325 CHECK_EQ(result, r.Call(*i)); 1332 CHECK_EQ(result, r.Call(*i));
1326 } 1333 }
1327 } 1334 }
1328 1335
1329 TEST(Run_WasmI64Shl) { 1336 TEST(Run_Wasm_I64Ror) {
1330 REQUIRE(I64Shl); 1337 REQUIRE(I64Ror);
1331 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); 1338 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64());
1332 BUILD(r, WASM_I64_SHL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 1339 BUILD(r, WASM_I64_ROR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
1333 1340
1334 FOR_UINT64_INPUTS(i) { 1341 FOR_UINT64_INPUTS(i) {
1335 FOR_UINT64_INPUTS(j) { 1342 FOR_UINT64_INPUTS(j) {
1336 uint64_t expected = (*i) << (*j & 0x3f); 1343 int64_t expected = bits::RotateRight64(*i, *j & 0x3f);
1337 CHECK_EQ(expected, r.Call(*i, *j)); 1344 CHECK_EQ(expected, r.Call(*i, *j));
1338 } 1345 }
1339 } 1346 }
1340 } 1347 }
1341 1348
1342 TEST(Run_WasmI64Shr) { 1349 TEST(Run_Wasm_I64Rol) {
1343 REQUIRE(I64ShrU); 1350 REQUIRE(I64Rol);
1344 WasmRunner<uint64_t> r(MachineType::Uint64(), MachineType::Uint64()); 1351 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64());
1345 BUILD(r, WASM_I64_SHR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1))); 1352 BUILD(r, WASM_I64_ROL(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
1346 1353
1347 FOR_UINT64_INPUTS(i) { 1354 FOR_UINT64_INPUTS(i) {
1348 FOR_UINT64_INPUTS(j) { 1355 FOR_UINT64_INPUTS(j) {
1349 uint64_t expected = (*i) >> (*j & 0x3f); 1356 int64_t expected = bits::RotateRight64(*i, 64 - (*j & 0x3f));
1350 CHECK_EQ(expected, r.Call(*i, *j)); 1357 CHECK_EQ(expected, r.Call(*i, *j));
1351 } 1358 }
1352 } 1359 }
1353 }
1354
1355 TEST(Run_WasmI64Sar) {
1356 REQUIRE(I64ShrS);
1357 WasmRunner<int64_t> r(MachineType::Int64(), MachineType::Int64());
1358 BUILD(r, WASM_I64_SAR(WASM_GET_LOCAL(0), WASM_GET_LOCAL(1)));
1359
1360 FOR_INT64_INPUTS(i) {
1361 FOR_INT64_INPUTS(j) {
1362 int64_t expected = (*i) >> (*j & 0x3f);
1363 CHECK_EQ(expected, r.Call(*i, *j));
1364 }
1365 }
1366 } 1360 }
OLDNEW
« no previous file with comments | « test/cctest/compiler/value-helper.h ('k') | test/unittests/compiler/int64-lowering-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698