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

Side by Side Diff: src/compiler/x64/code-generator-x64.cc

Issue 2170343002: [turbofan] Change Float64Max/Float64Min to JavaScript semantics. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: mips/mips64 ports. Created 4 years, 5 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/compiler/verifier.cc ('k') | src/compiler/x64/instruction-codes-x64.h » ('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 2013 the V8 project authors. All rights reserved. 1 // Copyright 2013 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/compiler/code-generator.h" 5 #include "src/compiler/code-generator.h"
6 6
7 #include "src/ast/scopes.h" 7 #include "src/ast/scopes.h"
8 #include "src/compiler/code-generator-impl.h" 8 #include "src/compiler/code-generator-impl.h"
9 #include "src/compiler/gap-resolver.h" 9 #include "src/compiler/gap-resolver.h"
10 #include "src/compiler/node-matchers.h" 10 #include "src/compiler/node-matchers.h"
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1189 case kSSEFloat32Neg: { 1189 case kSSEFloat32Neg: {
1190 // TODO(bmeurer): Use RIP relative 128-bit constants. 1190 // TODO(bmeurer): Use RIP relative 128-bit constants.
1191 __ pcmpeqd(kScratchDoubleReg, kScratchDoubleReg); 1191 __ pcmpeqd(kScratchDoubleReg, kScratchDoubleReg);
1192 __ psllq(kScratchDoubleReg, 31); 1192 __ psllq(kScratchDoubleReg, 31);
1193 __ xorps(i.OutputDoubleRegister(), kScratchDoubleReg); 1193 __ xorps(i.OutputDoubleRegister(), kScratchDoubleReg);
1194 break; 1194 break;
1195 } 1195 }
1196 case kSSEFloat32Sqrt: 1196 case kSSEFloat32Sqrt:
1197 ASSEMBLE_SSE_UNOP(sqrtss); 1197 ASSEMBLE_SSE_UNOP(sqrtss);
1198 break; 1198 break;
1199 case kSSEFloat32Max:
1200 ASSEMBLE_SSE_BINOP(maxss);
1201 break;
1202 case kSSEFloat32Min:
1203 ASSEMBLE_SSE_BINOP(minss);
1204 break;
1205 case kSSEFloat32ToFloat64: 1199 case kSSEFloat32ToFloat64:
1206 ASSEMBLE_SSE_UNOP(Cvtss2sd); 1200 ASSEMBLE_SSE_UNOP(Cvtss2sd);
1207 break; 1201 break;
1208 case kSSEFloat32Round: { 1202 case kSSEFloat32Round: {
1209 CpuFeatureScope sse_scope(masm(), SSE4_1); 1203 CpuFeatureScope sse_scope(masm(), SSE4_1);
1210 RoundingMode const mode = 1204 RoundingMode const mode =
1211 static_cast<RoundingMode>(MiscField::decode(instr->opcode())); 1205 static_cast<RoundingMode>(MiscField::decode(instr->opcode()));
1212 __ Roundss(i.OutputDoubleRegister(), i.InputDoubleRegister(0), mode); 1206 __ Roundss(i.OutputDoubleRegister(), i.InputDoubleRegister(0), mode);
1213 break; 1207 break;
1214 } 1208 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
1278 __ j(parity_even, &mod_loop); 1272 __ j(parity_even, &mod_loop);
1279 // Move output to stack and clean up. 1273 // Move output to stack and clean up.
1280 __ fstp(1); 1274 __ fstp(1);
1281 __ fstp_d(Operand(rsp, 0)); 1275 __ fstp_d(Operand(rsp, 0));
1282 __ Movsd(i.OutputDoubleRegister(), Operand(rsp, 0)); 1276 __ Movsd(i.OutputDoubleRegister(), Operand(rsp, 0));
1283 __ addq(rsp, Immediate(kDoubleSize)); 1277 __ addq(rsp, Immediate(kDoubleSize));
1284 unwinding_info_writer_.MaybeIncreaseBaseOffsetAt(__ pc_offset(), 1278 unwinding_info_writer_.MaybeIncreaseBaseOffsetAt(__ pc_offset(),
1285 -kDoubleSize); 1279 -kDoubleSize);
1286 break; 1280 break;
1287 } 1281 }
1288 case kSSEFloat64Max: 1282 case kSSEFloat64Max: {
1289 ASSEMBLE_SSE_BINOP(maxsd); 1283 Label compare_nan, compare_swap, done_compare;
1284 if (instr->InputAt(1)->IsFPRegister()) {
1285 __ Ucomisd(i.InputDoubleRegister(0), i.InputDoubleRegister(1));
1286 } else {
1287 __ Ucomisd(i.InputDoubleRegister(0), i.InputOperand(1));
1288 }
1289 auto ool = new (zone()) OutOfLineLoadNaN(this, i.OutputDoubleRegister());
1290 __ j(parity_even, ool->entry());
1291 __ j(above, &done_compare, Label::kNear);
1292 __ j(below, &compare_swap, Label::kNear);
1293 __ Movmskpd(kScratchRegister, i.InputDoubleRegister(0));
1294 __ testl(kScratchRegister, Immediate(1));
1295 __ j(zero, &done_compare, Label::kNear);
1296 __ bind(&compare_swap);
1297 if (instr->InputAt(1)->IsFPRegister()) {
1298 __ Movsd(i.InputDoubleRegister(0), i.InputDoubleRegister(1));
1299 } else {
1300 __ Movsd(i.InputDoubleRegister(0), i.InputOperand(1));
1301 }
1302 __ bind(&done_compare);
1303 __ bind(ool->exit());
1290 break; 1304 break;
1291 case kSSEFloat64Min: 1305 }
1292 ASSEMBLE_SSE_BINOP(minsd); 1306 case kSSEFloat64Min: {
1307 Label compare_swap, done_compare;
1308 if (instr->InputAt(1)->IsFPRegister()) {
1309 __ Ucomisd(i.InputDoubleRegister(0), i.InputDoubleRegister(1));
1310 } else {
1311 __ Ucomisd(i.InputDoubleRegister(0), i.InputOperand(1));
1312 }
1313 auto ool = new (zone()) OutOfLineLoadNaN(this, i.OutputDoubleRegister());
1314 __ j(parity_even, ool->entry());
1315 __ j(below, &done_compare, Label::kNear);
1316 __ j(above, &compare_swap, Label::kNear);
1317 if (instr->InputAt(1)->IsFPRegister()) {
1318 __ Movmskpd(kScratchRegister, i.InputDoubleRegister(1));
1319 } else {
1320 __ Movsd(kScratchDoubleReg, i.InputOperand(1));
1321 __ Movmskpd(kScratchRegister, kScratchDoubleReg);
1322 }
1323 __ testl(kScratchRegister, Immediate(1));
1324 __ j(zero, &done_compare, Label::kNear);
1325 __ bind(&compare_swap);
1326 if (instr->InputAt(1)->IsFPRegister()) {
1327 __ Movsd(i.InputDoubleRegister(0), i.InputDoubleRegister(1));
1328 } else {
1329 __ Movsd(i.InputDoubleRegister(0), i.InputOperand(1));
1330 }
1331 __ bind(&done_compare);
1332 __ bind(ool->exit());
1293 break; 1333 break;
1334 }
1294 case kSSEFloat64Abs: { 1335 case kSSEFloat64Abs: {
1295 // TODO(bmeurer): Use RIP relative 128-bit constants. 1336 // TODO(bmeurer): Use RIP relative 128-bit constants.
1296 __ pcmpeqd(kScratchDoubleReg, kScratchDoubleReg); 1337 __ pcmpeqd(kScratchDoubleReg, kScratchDoubleReg);
1297 __ psrlq(kScratchDoubleReg, 1); 1338 __ psrlq(kScratchDoubleReg, 1);
1298 __ andpd(i.OutputDoubleRegister(), kScratchDoubleReg); 1339 __ andpd(i.OutputDoubleRegister(), kScratchDoubleReg);
1299 break; 1340 break;
1300 } 1341 }
1301 case kSSEFloat64Neg: { 1342 case kSSEFloat64Neg: {
1302 // TODO(bmeurer): Use RIP relative 128-bit constants. 1343 // TODO(bmeurer): Use RIP relative 128-bit constants.
1303 __ pcmpeqd(kScratchDoubleReg, kScratchDoubleReg); 1344 __ pcmpeqd(kScratchDoubleReg, kScratchDoubleReg);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
1594 break; 1635 break;
1595 case kAVXFloat32Mul: 1636 case kAVXFloat32Mul:
1596 ASSEMBLE_AVX_BINOP(vmulss); 1637 ASSEMBLE_AVX_BINOP(vmulss);
1597 break; 1638 break;
1598 case kAVXFloat32Div: 1639 case kAVXFloat32Div:
1599 ASSEMBLE_AVX_BINOP(vdivss); 1640 ASSEMBLE_AVX_BINOP(vdivss);
1600 // Don't delete this mov. It may improve performance on some CPUs, 1641 // Don't delete this mov. It may improve performance on some CPUs,
1601 // when there is a (v)mulss depending on the result. 1642 // when there is a (v)mulss depending on the result.
1602 __ Movaps(i.OutputDoubleRegister(), i.OutputDoubleRegister()); 1643 __ Movaps(i.OutputDoubleRegister(), i.OutputDoubleRegister());
1603 break; 1644 break;
1604 case kAVXFloat32Max:
1605 ASSEMBLE_AVX_BINOP(vmaxss);
1606 break;
1607 case kAVXFloat32Min:
1608 ASSEMBLE_AVX_BINOP(vminss);
1609 break;
1610 case kAVXFloat64Cmp: { 1645 case kAVXFloat64Cmp: {
1611 CpuFeatureScope avx_scope(masm(), AVX); 1646 CpuFeatureScope avx_scope(masm(), AVX);
1612 if (instr->InputAt(1)->IsFPRegister()) { 1647 if (instr->InputAt(1)->IsFPRegister()) {
1613 __ vucomisd(i.InputDoubleRegister(0), i.InputDoubleRegister(1)); 1648 __ vucomisd(i.InputDoubleRegister(0), i.InputDoubleRegister(1));
1614 } else { 1649 } else {
1615 __ vucomisd(i.InputDoubleRegister(0), i.InputOperand(1)); 1650 __ vucomisd(i.InputDoubleRegister(0), i.InputOperand(1));
1616 } 1651 }
1617 break; 1652 break;
1618 } 1653 }
1619 case kAVXFloat64Add: 1654 case kAVXFloat64Add:
1620 ASSEMBLE_AVX_BINOP(vaddsd); 1655 ASSEMBLE_AVX_BINOP(vaddsd);
1621 break; 1656 break;
1622 case kAVXFloat64Sub: 1657 case kAVXFloat64Sub:
1623 ASSEMBLE_AVX_BINOP(vsubsd); 1658 ASSEMBLE_AVX_BINOP(vsubsd);
1624 break; 1659 break;
1625 case kAVXFloat64Mul: 1660 case kAVXFloat64Mul:
1626 ASSEMBLE_AVX_BINOP(vmulsd); 1661 ASSEMBLE_AVX_BINOP(vmulsd);
1627 break; 1662 break;
1628 case kAVXFloat64Div: 1663 case kAVXFloat64Div:
1629 ASSEMBLE_AVX_BINOP(vdivsd); 1664 ASSEMBLE_AVX_BINOP(vdivsd);
1630 // Don't delete this mov. It may improve performance on some CPUs, 1665 // Don't delete this mov. It may improve performance on some CPUs,
1631 // when there is a (v)mulsd depending on the result. 1666 // when there is a (v)mulsd depending on the result.
1632 __ Movapd(i.OutputDoubleRegister(), i.OutputDoubleRegister()); 1667 __ Movapd(i.OutputDoubleRegister(), i.OutputDoubleRegister());
1633 break; 1668 break;
1634 case kAVXFloat64Max:
1635 ASSEMBLE_AVX_BINOP(vmaxsd);
1636 break;
1637 case kAVXFloat64Min:
1638 ASSEMBLE_AVX_BINOP(vminsd);
1639 break;
1640 case kAVXFloat32Abs: { 1669 case kAVXFloat32Abs: {
1641 // TODO(bmeurer): Use RIP relative 128-bit constants. 1670 // TODO(bmeurer): Use RIP relative 128-bit constants.
1642 CpuFeatureScope avx_scope(masm(), AVX); 1671 CpuFeatureScope avx_scope(masm(), AVX);
1643 __ vpcmpeqd(kScratchDoubleReg, kScratchDoubleReg, kScratchDoubleReg); 1672 __ vpcmpeqd(kScratchDoubleReg, kScratchDoubleReg, kScratchDoubleReg);
1644 __ vpsrlq(kScratchDoubleReg, kScratchDoubleReg, 33); 1673 __ vpsrlq(kScratchDoubleReg, kScratchDoubleReg, 33);
1645 if (instr->InputAt(0)->IsFPRegister()) { 1674 if (instr->InputAt(0)->IsFPRegister()) {
1646 __ vandps(i.OutputDoubleRegister(), kScratchDoubleReg, 1675 __ vandps(i.OutputDoubleRegister(), kScratchDoubleReg,
1647 i.InputDoubleRegister(0)); 1676 i.InputDoubleRegister(0));
1648 } else { 1677 } else {
1649 __ vandps(i.OutputDoubleRegister(), kScratchDoubleReg, 1678 __ vandps(i.OutputDoubleRegister(), kScratchDoubleReg,
(...skipping 893 matching lines...) Expand 10 before | Expand all | Expand 10 after
2543 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc; 2572 int padding_size = last_lazy_deopt_pc_ + space_needed - current_pc;
2544 __ Nop(padding_size); 2573 __ Nop(padding_size);
2545 } 2574 }
2546 } 2575 }
2547 2576
2548 #undef __ 2577 #undef __
2549 2578
2550 } // namespace compiler 2579 } // namespace compiler
2551 } // namespace internal 2580 } // namespace internal
2552 } // namespace v8 2581 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/verifier.cc ('k') | src/compiler/x64/instruction-codes-x64.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698