OLD | NEW |
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 Loading... |
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 Loading... |
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 Loading... |
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 |
OLD | NEW |