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

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

Issue 1584663007: [turbofan] Implement rounding of floats on x64 and ia32 without sse4.1. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: reduced generated code. Created 4 years, 11 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/ia32/code-generator-ia32.cc ('k') | src/compiler/x64/code-generator-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 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 "src/base/adapters.h" 5 #include "src/base/adapters.h"
6 #include "src/compiler/instruction-selector-impl.h" 6 #include "src/compiler/instruction-selector-impl.h"
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 #include "src/compiler/node-properties.h" 8 #include "src/compiler/node-properties.h"
9 9
10 namespace v8 { 10 namespace v8 {
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
778 void InstructionSelector::VisitFloat64Sub(Node* node) { 778 void InstructionSelector::VisitFloat64Sub(Node* node) {
779 IA32OperandGenerator g(this); 779 IA32OperandGenerator g(this);
780 Float64BinopMatcher m(node); 780 Float64BinopMatcher m(node);
781 if (m.left().IsMinusZero()) { 781 if (m.left().IsMinusZero()) {
782 if (m.right().IsFloat64RoundDown() && 782 if (m.right().IsFloat64RoundDown() &&
783 CanCover(m.node(), m.right().node())) { 783 CanCover(m.node(), m.right().node())) {
784 if (m.right().InputAt(0)->opcode() == IrOpcode::kFloat64Sub && 784 if (m.right().InputAt(0)->opcode() == IrOpcode::kFloat64Sub &&
785 CanCover(m.right().node(), m.right().InputAt(0))) { 785 CanCover(m.right().node(), m.right().InputAt(0))) {
786 Float64BinopMatcher mright0(m.right().InputAt(0)); 786 Float64BinopMatcher mright0(m.right().InputAt(0));
787 if (mright0.left().IsMinusZero()) { 787 if (mright0.left().IsMinusZero()) {
788 Emit(kSSEFloat64Round | MiscField::encode(kRoundUp), 788 if (CpuFeatures::IsSupported(SSE4_1)) {
789 g.DefineAsRegister(node), g.UseRegister(mright0.right().node())); 789 Emit(kSSEFloat64Round | MiscField::encode(kRoundUp),
790 g.DefineAsRegister(node),
791 g.UseRegister(mright0.right().node()));
792 } else {
793 IA32OperandGenerator g(this);
794 InstructionOperand temps[] = {g.TempRegister()};
795 Emit(kSSEFloat64Round | MiscField::encode(kRoundUp),
796 g.DefineAsRegister(node),
797 g.UseRegister(mright0.right().node()), 1, temps);
798 }
790 return; 799 return;
791 } 800 }
792 } 801 }
793 } 802 }
794 VisitFloatUnop(this, node, m.right().node(), kAVXFloat64Neg, 803 VisitFloatUnop(this, node, m.right().node(), kAVXFloat64Neg,
795 kSSEFloat64Neg); 804 kSSEFloat64Neg);
796 return; 805 return;
797 } 806 }
798 VisitRROFloat(this, node, kAVXFloat64Sub, kSSEFloat64Sub); 807 VisitRROFloat(this, node, kAVXFloat64Sub, kSSEFloat64Sub);
799 } 808 }
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 VisitRO(this, node, kSSEFloat32Sqrt); 873 VisitRO(this, node, kSSEFloat32Sqrt);
865 } 874 }
866 875
867 876
868 void InstructionSelector::VisitFloat64Sqrt(Node* node) { 877 void InstructionSelector::VisitFloat64Sqrt(Node* node) {
869 VisitRO(this, node, kSSEFloat64Sqrt); 878 VisitRO(this, node, kSSEFloat64Sqrt);
870 } 879 }
871 880
872 881
873 void InstructionSelector::VisitFloat32RoundDown(Node* node) { 882 void InstructionSelector::VisitFloat32RoundDown(Node* node) {
874 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundDown)); 883 if (CpuFeatures::IsSupported(SSE4_1)) {
884 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundDown));
885 } else {
886 IA32OperandGenerator g(this);
887 InstructionOperand temps[] = {g.TempRegister()};
888 Emit(kSSEFloat32Round | MiscField::encode(kRoundDown),
889 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps);
890 }
875 } 891 }
876 892
877 893
878 void InstructionSelector::VisitFloat64RoundDown(Node* node) { 894 void InstructionSelector::VisitFloat64RoundDown(Node* node) {
879 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundDown)); 895 if (CpuFeatures::IsSupported(SSE4_1)) {
896 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundDown));
897 } else {
898 IA32OperandGenerator g(this);
899 InstructionOperand temps[] = {g.TempRegister()};
900 Emit(kSSEFloat64Round | MiscField::encode(kRoundDown),
901 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps);
902 }
880 } 903 }
881 904
882 905
883 void InstructionSelector::VisitFloat32RoundUp(Node* node) { 906 void InstructionSelector::VisitFloat32RoundUp(Node* node) {
884 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundUp)); 907 if (CpuFeatures::IsSupported(SSE4_1)) {
908 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundUp));
909 } else {
910 IA32OperandGenerator g(this);
911 InstructionOperand temps[] = {g.TempRegister()};
912 Emit(kSSEFloat32Round | MiscField::encode(kRoundUp),
913 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps);
914 }
885 } 915 }
886 916
887 917
888 void InstructionSelector::VisitFloat64RoundUp(Node* node) { 918 void InstructionSelector::VisitFloat64RoundUp(Node* node) {
889 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundUp)); 919 if (CpuFeatures::IsSupported(SSE4_1)) {
920 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundUp));
921 } else {
922 IA32OperandGenerator g(this);
923 InstructionOperand temps[] = {g.TempRegister()};
924 Emit(kSSEFloat64Round | MiscField::encode(kRoundUp),
925 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps);
926 }
890 } 927 }
891 928
892 929
893 void InstructionSelector::VisitFloat32RoundTruncate(Node* node) { 930 void InstructionSelector::VisitFloat32RoundTruncate(Node* node) {
894 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundToZero)); 931 if (CpuFeatures::IsSupported(SSE4_1)) {
932 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundToZero));
933 } else {
934 IA32OperandGenerator g(this);
935 InstructionOperand temps[] = {g.TempRegister()};
936 Emit(kSSEFloat32Round | MiscField::encode(kRoundToZero),
937 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps);
938 }
895 } 939 }
896 940
897 941
898 void InstructionSelector::VisitFloat64RoundTruncate(Node* node) { 942 void InstructionSelector::VisitFloat64RoundTruncate(Node* node) {
899 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundToZero)); 943 if (CpuFeatures::IsSupported(SSE4_1)) {
944 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundToZero));
945 } else {
946 IA32OperandGenerator g(this);
947 InstructionOperand temps[] = {g.TempRegister()};
948 Emit(kSSEFloat64Round | MiscField::encode(kRoundToZero),
949 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps);
950 }
900 } 951 }
901 952
902 953
903 void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) { 954 void InstructionSelector::VisitFloat64RoundTiesAway(Node* node) {
904 UNREACHABLE(); 955 UNREACHABLE();
905 } 956 }
906 957
907 958
908 void InstructionSelector::VisitFloat32RoundTiesEven(Node* node) { 959 void InstructionSelector::VisitFloat32RoundTiesEven(Node* node) {
909 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundToNearest)); 960 if (CpuFeatures::IsSupported(SSE4_1)) {
961 VisitRR(this, node, kSSEFloat32Round | MiscField::encode(kRoundToNearest));
962 } else {
963 IA32OperandGenerator g(this);
964 InstructionOperand temps[] = {g.TempRegister()};
965 Emit(kSSEFloat32Round | MiscField::encode(kRoundToNearest),
966 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps);
967 }
910 } 968 }
911 969
912 970
913 void InstructionSelector::VisitFloat64RoundTiesEven(Node* node) { 971 void InstructionSelector::VisitFloat64RoundTiesEven(Node* node) {
914 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundToNearest)); 972 if (CpuFeatures::IsSupported(SSE4_1)) {
973 VisitRR(this, node, kSSEFloat64Round | MiscField::encode(kRoundToNearest));
974 } else {
975 IA32OperandGenerator g(this);
976 InstructionOperand temps[] = {g.TempRegister()};
977 Emit(kSSEFloat64Round | MiscField::encode(kRoundToNearest),
978 g.DefineSameAsFirst(node), g.UseRegister(node->InputAt(0)), 1, temps);
979 }
915 } 980 }
916 981
917 982
918 void InstructionSelector::EmitPrepareArguments( 983 void InstructionSelector::EmitPrepareArguments(
919 ZoneVector<PushParameter>* arguments, const CallDescriptor* descriptor, 984 ZoneVector<PushParameter>* arguments, const CallDescriptor* descriptor,
920 Node* node) { 985 Node* node) {
921 IA32OperandGenerator g(this); 986 IA32OperandGenerator g(this);
922 987
923 // Prepare for C function call. 988 // Prepare for C function call.
924 if (descriptor->IsCFunctionCall()) { 989 if (descriptor->IsCFunctionCall()) {
(...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after
1316 1381
1317 // static 1382 // static
1318 MachineOperatorBuilder::Flags 1383 MachineOperatorBuilder::Flags
1319 InstructionSelector::SupportedMachineOperatorFlags() { 1384 InstructionSelector::SupportedMachineOperatorFlags() {
1320 MachineOperatorBuilder::Flags flags = 1385 MachineOperatorBuilder::Flags flags =
1321 MachineOperatorBuilder::kFloat32Max | 1386 MachineOperatorBuilder::kFloat32Max |
1322 MachineOperatorBuilder::kFloat32Min | 1387 MachineOperatorBuilder::kFloat32Min |
1323 MachineOperatorBuilder::kFloat64Max | 1388 MachineOperatorBuilder::kFloat64Max |
1324 MachineOperatorBuilder::kFloat64Min | 1389 MachineOperatorBuilder::kFloat64Min |
1325 MachineOperatorBuilder::kWord32ShiftIsSafe | 1390 MachineOperatorBuilder::kWord32ShiftIsSafe |
1326 MachineOperatorBuilder::kWord32Ctz; 1391 MachineOperatorBuilder::kWord32Ctz |
1392 MachineOperatorBuilder::kFloat32RoundDown |
1393 MachineOperatorBuilder::kFloat32RoundUp |
1394 MachineOperatorBuilder::kFloat32RoundTruncate |
1395 MachineOperatorBuilder::kFloat32RoundTiesEven |
1396 MachineOperatorBuilder::kFloat64RoundDown |
1397 MachineOperatorBuilder::kFloat64RoundUp |
1398 MachineOperatorBuilder::kFloat64RoundTruncate |
1399 MachineOperatorBuilder::kFloat64RoundTiesEven;
1400
1327 if (CpuFeatures::IsSupported(POPCNT)) { 1401 if (CpuFeatures::IsSupported(POPCNT)) {
1328 flags |= MachineOperatorBuilder::kWord32Popcnt; 1402 flags |= MachineOperatorBuilder::kWord32Popcnt;
1329 } 1403 }
1330 if (CpuFeatures::IsSupported(SSE4_1)) {
1331 flags |= MachineOperatorBuilder::kFloat32RoundDown |
1332 MachineOperatorBuilder::kFloat64RoundDown |
1333 MachineOperatorBuilder::kFloat32RoundUp |
1334 MachineOperatorBuilder::kFloat64RoundUp |
1335 MachineOperatorBuilder::kFloat32RoundTruncate |
1336 MachineOperatorBuilder::kFloat64RoundTruncate |
1337 MachineOperatorBuilder::kFloat32RoundTiesEven |
1338 MachineOperatorBuilder::kFloat64RoundTiesEven;
1339 }
1340 return flags; 1404 return flags;
1341 } 1405 }
1342 1406
1343 } // namespace compiler 1407 } // namespace compiler
1344 } // namespace internal 1408 } // namespace internal
1345 } // namespace v8 1409 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/ia32/code-generator-ia32.cc ('k') | src/compiler/x64/code-generator-x64.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698