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

Side by Side Diff: test/cctest/test-assembler-x64.cc

Issue 1406353003: [x64] Emit vcvttsd2si[q] when AVX is enabled. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | test/cctest/test-disasm-x64.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 2009 the V8 project authors. All rights reserved. 1 // Copyright 2009 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 1333 matching lines...) Expand 10 before | Expand all | Expand 10 after
1344 if (!CpuFeatures::IsSupported(AVX)) return; 1344 if (!CpuFeatures::IsSupported(AVX)) return;
1345 1345
1346 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate()); 1346 Isolate* isolate = reinterpret_cast<Isolate*>(CcTest::isolate());
1347 HandleScope scope(isolate); 1347 HandleScope scope(isolate);
1348 v8::internal::byte buffer[1024]; 1348 v8::internal::byte buffer[1024];
1349 Assembler assm(isolate, buffer, sizeof(buffer)); 1349 Assembler assm(isolate, buffer, sizeof(buffer));
1350 { 1350 {
1351 CpuFeatureScope avx_scope(&assm, AVX); 1351 CpuFeatureScope avx_scope(&assm, AVX);
1352 Label exit; 1352 Label exit;
1353 // arguments in xmm0, xmm1 and xmm2 1353 // arguments in xmm0, xmm1 and xmm2
1354 __ subq(rsp, Immediate(kDoubleSize * 2)); // For memory operand
1354 __ movl(rax, Immediate(0)); 1355 __ movl(rax, Immediate(0));
1355 1356
1356 __ vmaxsd(xmm4, xmm0, xmm1); 1357 __ vmaxsd(xmm4, xmm0, xmm1);
1357 __ subq(rsp, Immediate(kDoubleSize * 2)); // For memory operand
1358 __ vmovsd(Operand(rsp, kDoubleSize), xmm4); 1358 __ vmovsd(Operand(rsp, kDoubleSize), xmm4);
1359 __ vmovsd(xmm5, Operand(rsp, kDoubleSize)); 1359 __ vmovsd(xmm5, Operand(rsp, kDoubleSize));
1360 __ vmovsd(xmm6, xmm5); 1360 __ vmovsd(xmm6, xmm5);
1361 __ vmovapd(xmm3, xmm6); 1361 __ vmovapd(xmm3, xmm6);
1362 1362
1363 // Test vcvttsd2si
1364 __ movl(rax, Immediate(10));
1365 __ movl(rdx, Immediate(123));
1366 __ vcvtlsi2sd(xmm6, xmm6, rdx);
1367 __ vcvttsd2si(rcx, xmm6);
1368 __ cmpl(rcx, rdx);
1369 __ j(not_equal, &exit);
1370 __ xorl(rcx, rcx);
1371 __ vmovsd(Operand(rsp, 0), xmm6);
1372 __ vcvttsd2si(rcx, Operand(rsp, 0));
1373 __ cmpl(rcx, rdx);
1374 __ j(not_equal, &exit);
1375
1376 // Test vcvttsd2siq
1377 __ movl(rax, Immediate(11));
1378 __ movq(rdx, V8_INT64_C(0x426D1A94A2000000)); // 1.0e12
1379 __ vmovq(xmm6, rdx);
1380 __ vcvttsd2siq(rcx, xmm6);
1381 __ movq(rdx, V8_INT64_C(1000000000000));
1382 __ cmpq(rcx, rdx);
1383 __ j(not_equal, &exit);
1384 __ xorq(rcx, rcx);
1385 __ vmovsd(Operand(rsp, 0), xmm6);
1386 __ vcvttsd2siq(rcx, Operand(rsp, 0));
1387 __ cmpq(rcx, rdx);
1388 __ j(not_equal, &exit);
1389
1363 __ movl(rdx, Immediate(6)); 1390 __ movl(rdx, Immediate(6));
1364 __ vcvtlsi2sd(xmm6, xmm6, rdx); 1391 __ vcvtlsi2sd(xmm6, xmm6, rdx);
1365 __ movl(Operand(rsp, 0), Immediate(5)); 1392 __ movl(Operand(rsp, 0), Immediate(5));
1366 __ vcvtlsi2sd(xmm7, xmm7, Operand(rsp, 0)); 1393 __ vcvtlsi2sd(xmm7, xmm7, Operand(rsp, 0));
1367 __ vsubsd(xmm7, xmm6, xmm7); // xmm7 is 1.0 1394 __ vsubsd(xmm7, xmm6, xmm7); // xmm7 is 1.0
1368 __ vmulsd(xmm1, xmm1, xmm7); 1395 __ vmulsd(xmm1, xmm1, xmm7);
1369 1396
1370 __ movq(rdx, V8_INT64_C(0x3ff0000000000000)); // 1.0 1397 __ movq(rdx, V8_INT64_C(0x3ff0000000000000)); // 1.0
1371 __ vmovq(xmm7, rdx); 1398 __ vmovq(xmm7, rdx);
1372 __ vmulsd(xmm1, xmm1, xmm7); 1399 __ vmulsd(xmm1, xmm1, xmm7);
1373 __ movq(Operand(rsp, 0), rdx); 1400 __ movq(Operand(rsp, 0), rdx);
1374 __ vmovq(xmm6, Operand(rsp, 0)); 1401 __ vmovq(xmm6, Operand(rsp, 0));
1375 __ vmulsd(xmm1, xmm1, xmm6); 1402 __ vmulsd(xmm1, xmm1, xmm6);
1376 __ addq(rsp, Immediate(kDoubleSize * 2));
1377 1403
1378 __ vucomisd(xmm3, xmm1); 1404 __ vucomisd(xmm3, xmm1);
1379 __ j(parity_even, &exit); 1405 __ j(parity_even, &exit);
1380 __ j(not_equal, &exit); 1406 __ j(not_equal, &exit);
1381 __ movl(rax, Immediate(1)); 1407 __ movl(rax, Immediate(1));
1382 1408
1383 __ vminsd(xmm3, xmm1, xmm2); 1409 __ vminsd(xmm3, xmm1, xmm2);
1384 __ vucomisd(xmm3, xmm1); 1410 __ vucomisd(xmm3, xmm1);
1385 __ j(parity_even, &exit); 1411 __ j(parity_even, &exit);
1386 __ j(not_equal, &exit); 1412 __ j(not_equal, &exit);
(...skipping 20 matching lines...) Expand all
1407 __ vdivsd(xmm3, xmm0, xmm1); 1433 __ vdivsd(xmm3, xmm0, xmm1);
1408 __ vmulsd(xmm3, xmm3, xmm2); 1434 __ vmulsd(xmm3, xmm3, xmm2);
1409 __ vmulsd(xmm3, xmm3, xmm1); 1435 __ vmulsd(xmm3, xmm3, xmm1);
1410 __ vucomisd(xmm3, xmm2); 1436 __ vucomisd(xmm3, xmm2);
1411 __ j(parity_even, &exit); 1437 __ j(parity_even, &exit);
1412 __ j(not_equal, &exit); 1438 __ j(not_equal, &exit);
1413 __ movl(rax, Immediate(6)); 1439 __ movl(rax, Immediate(6));
1414 1440
1415 // result in eax 1441 // result in eax
1416 __ bind(&exit); 1442 __ bind(&exit);
1443 __ addq(rsp, Immediate(kDoubleSize * 2));
1417 __ ret(0); 1444 __ ret(0);
1418 } 1445 }
1419 1446
1420 CodeDesc desc; 1447 CodeDesc desc;
1421 assm.GetCode(&desc); 1448 assm.GetCode(&desc);
1422 Handle<Code> code = isolate->factory()->NewCode( 1449 Handle<Code> code = isolate->factory()->NewCode(
1423 desc, Code::ComputeFlags(Code::STUB), Handle<Code>()); 1450 desc, Code::ComputeFlags(Code::STUB), Handle<Code>());
1424 #ifdef OBJECT_PRINT 1451 #ifdef OBJECT_PRINT
1425 OFStream os(stdout); 1452 OFStream os(stdout);
1426 code->Print(os); 1453 code->Print(os);
(...skipping 663 matching lines...) Expand 10 before | Expand all | Expand 10 after
2090 2117
2091 F1 f = FUNCTION_CAST<F1>(code->entry()); 2118 F1 f = FUNCTION_CAST<F1>(code->entry());
2092 for (int i = 0; i < kNumCases; ++i) { 2119 for (int i = 0; i < kNumCases; ++i) {
2093 int res = f(i); 2120 int res = f(i);
2094 PrintF("f(%d) = %d\n", i, res); 2121 PrintF("f(%d) = %d\n", i, res);
2095 CHECK_EQ(values[i], res); 2122 CHECK_EQ(values[i], res);
2096 } 2123 }
2097 } 2124 }
2098 2125
2099 #undef __ 2126 #undef __
OLDNEW
« no previous file with comments | « src/x64/macro-assembler-x64.cc ('k') | test/cctest/test-disasm-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698