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

Side by Side Diff: src/compiler/x64/instruction-selector-x64.cc

Issue 990963003: [turbofan] Unify Math.floor / Math.ceil optimization. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 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 | « src/compiler/x64/instruction-codes-x64.h ('k') | src/hydrogen.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 2014 the V8 project authors. All rights reserved. 1 // Copyright 2014 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 <algorithm> 5 #include <algorithm>
6 6
7 #include "src/compiler/instruction-selector-impl.h" 7 #include "src/compiler/instruction-selector-impl.h"
8 #include "src/compiler/node-matchers.h" 8 #include "src/compiler/node-matchers.h"
9 #include "src/compiler/node-properties.h" 9 #include "src/compiler/node-properties.h"
10 10
(...skipping 826 matching lines...) Expand 10 before | Expand all | Expand 10 after
837 g.UseRegister(node->InputAt(0)), g.Use(node->InputAt(1))); 837 g.UseRegister(node->InputAt(0)), g.Use(node->InputAt(1)));
838 } else { 838 } else {
839 Emit(kSSEFloat64Add, g.DefineSameAsFirst(node), 839 Emit(kSSEFloat64Add, g.DefineSameAsFirst(node),
840 g.UseRegister(node->InputAt(0)), g.Use(node->InputAt(1))); 840 g.UseRegister(node->InputAt(0)), g.Use(node->InputAt(1)));
841 } 841 }
842 } 842 }
843 843
844 844
845 void InstructionSelector::VisitFloat64Sub(Node* node) { 845 void InstructionSelector::VisitFloat64Sub(Node* node) {
846 X64OperandGenerator g(this); 846 X64OperandGenerator g(this);
847 Float64BinopMatcher m(node);
848 if (m.left().IsMinusZero() && m.right().IsFloat64RoundDown() &&
849 CanCover(m.node(), m.right().node())) {
850 if (m.right().InputAt(0)->opcode() == IrOpcode::kFloat64Sub &&
851 CanCover(m.right().node(), m.right().InputAt(0))) {
852 Float64BinopMatcher mright0(m.right().InputAt(0));
853 if (mright0.left().IsMinusZero()) {
854 Emit(kSSEFloat64Round | MiscField::encode(kRoundUp),
855 g.DefineAsRegister(node), g.UseRegister(mright0.right().node()));
856 return;
857 }
858 }
859 }
847 if (IsSupported(AVX)) { 860 if (IsSupported(AVX)) {
848 Emit(kAVXFloat64Sub, g.DefineAsRegister(node), 861 Emit(kAVXFloat64Sub, g.DefineAsRegister(node),
849 g.UseRegister(node->InputAt(0)), g.Use(node->InputAt(1))); 862 g.UseRegister(node->InputAt(0)), g.Use(node->InputAt(1)));
850 } else { 863 } else {
851 Emit(kSSEFloat64Sub, g.DefineSameAsFirst(node), 864 Emit(kSSEFloat64Sub, g.DefineSameAsFirst(node),
852 g.UseRegister(node->InputAt(0)), g.Use(node->InputAt(1))); 865 g.UseRegister(node->InputAt(0)), g.Use(node->InputAt(1)));
853 } 866 }
854 } 867 }
855 868
856 869
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
888 901
889 902
890 void InstructionSelector::VisitFloat64Sqrt(Node* node) { 903 void InstructionSelector::VisitFloat64Sqrt(Node* node) {
891 X64OperandGenerator g(this); 904 X64OperandGenerator g(this);
892 Emit(kSSEFloat64Sqrt, g.DefineAsRegister(node), g.Use(node->InputAt(0))); 905 Emit(kSSEFloat64Sqrt, g.DefineAsRegister(node), g.Use(node->InputAt(0)));
893 } 906 }
894 907
895 908
896 namespace { 909 namespace {
897 910
898 void VisitRRFloat64(InstructionSelector* selector, ArchOpcode opcode, 911 void VisitRRFloat64(InstructionSelector* selector, InstructionCode opcode,
899 Node* node) { 912 Node* node) {
900 X64OperandGenerator g(selector); 913 X64OperandGenerator g(selector);
901 selector->Emit(opcode, g.DefineAsRegister(node), 914 selector->Emit(opcode, g.DefineAsRegister(node),
902 g.UseRegister(node->InputAt(0))); 915 g.UseRegister(node->InputAt(0)));
903 } 916 }
904 917
905 } // namespace 918 } // namespace
906 919
907 920
908 void InstructionSelector::VisitFloat64Floor(Node* node) { 921 void InstructionSelector::VisitFloat64RoundDown(Node* node) {
909 DCHECK(CpuFeatures::IsSupported(SSE4_1)); 922 VisitRRFloat64(this, kSSEFloat64Round | MiscField::encode(kRoundDown), node);
910 VisitRRFloat64(this, kSSEFloat64Floor, node);
911 }
912
913
914 void InstructionSelector::VisitFloat64Ceil(Node* node) {
915 DCHECK(CpuFeatures::IsSupported(SSE4_1));
916 VisitRRFloat64(this, kSSEFloat64Ceil, node);
917 } 923 }
918 924
919 925
920 void InstructionSelector::VisitFloat64RoundTruncate(Node* node) { 926 void InstructionSelector::VisitFloat64RoundTruncate(Node* node) {
921 DCHECK(CpuFeatures::IsSupported(SSE4_1)); 927 VisitRRFloat64(this, kSSEFloat64Round | MiscField::encode(kRoundToZero),
922 VisitRRFloat64(this, kSSEFloat64RoundTruncate, node); 928 node);
923 } 929 }
924 930
925 931
926 void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) { 932 void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) {
927 UNREACHABLE(); 933 UNREACHABLE();
928 } 934 }
929 935
930 936
931 void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) { 937 void InstructionSelector::VisitCall(Node* node, BasicBlock* handler) {
932 X64OperandGenerator g(this); 938 X64OperandGenerator g(this);
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after
1438 g.UseRegister(left), g.Use(right)); 1444 g.UseRegister(left), g.Use(right));
1439 } 1445 }
1440 1446
1441 1447
1442 // static 1448 // static
1443 MachineOperatorBuilder::Flags 1449 MachineOperatorBuilder::Flags
1444 InstructionSelector::SupportedMachineOperatorFlags() { 1450 InstructionSelector::SupportedMachineOperatorFlags() {
1445 MachineOperatorBuilder::Flags flags = 1451 MachineOperatorBuilder::Flags flags =
1446 MachineOperatorBuilder::kWord32ShiftIsSafe; 1452 MachineOperatorBuilder::kWord32ShiftIsSafe;
1447 if (CpuFeatures::IsSupported(SSE4_1)) { 1453 if (CpuFeatures::IsSupported(SSE4_1)) {
1448 flags |= MachineOperatorBuilder::kFloat64Floor | 1454 flags |= MachineOperatorBuilder::kFloat64RoundDown |
1449 MachineOperatorBuilder::kFloat64Ceil |
1450 MachineOperatorBuilder::kFloat64RoundTruncate; 1455 MachineOperatorBuilder::kFloat64RoundTruncate;
1451 } 1456 }
1452 return flags; 1457 return flags;
1453 } 1458 }
1454 1459
1455 } // namespace compiler 1460 } // namespace compiler
1456 } // namespace internal 1461 } // namespace internal
1457 } // namespace v8 1462 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/x64/instruction-codes-x64.h ('k') | src/hydrogen.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698