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

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

Issue 1520503002: MIPS: [turbofan] Optimize Float32 to Int32 rep. changes with Float32 round ops. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years 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
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/base/bits.h" 6 #include "src/base/bits.h"
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 819 matching lines...) Expand 10 before | Expand all | Expand 10 after
830 return; 830 return;
831 case IrOpcode::kFloat64RoundTiesEven: 831 case IrOpcode::kFloat64RoundTiesEven:
832 Emit(kMips64RoundWD, g.DefineAsRegister(node), 832 Emit(kMips64RoundWD, g.DefineAsRegister(node),
833 g.UseRegister(value->InputAt(0))); 833 g.UseRegister(value->InputAt(0)));
834 return; 834 return;
835 case IrOpcode::kFloat64RoundTruncate: 835 case IrOpcode::kFloat64RoundTruncate:
836 Emit(kMips64TruncWD, g.DefineAsRegister(node), 836 Emit(kMips64TruncWD, g.DefineAsRegister(node),
837 g.UseRegister(value->InputAt(0))); 837 g.UseRegister(value->InputAt(0)));
838 return; 838 return;
839 default: 839 default:
840 VisitRR(this, kMips64TruncWD, node); 840 break;
841 }
842 if (value->opcode() == IrOpcode::kChangeFloat32ToFloat64) {
843 Node* next = value->InputAt(0);
844 if (CanCover(value, next)) {
845 // Match ChangeFloat64ToInt32(ChangeFloat32ToFloat64(Float64Round##OP))
846 switch (next->opcode()) {
847 case IrOpcode::kFloat32RoundDown:
848 Emit(kMips64FloorWS, g.DefineAsRegister(node),
849 g.UseRegister(next->InputAt(0)));
850 return;
851 case IrOpcode::kFloat32RoundUp:
852 Emit(kMips64CeilWS, g.DefineAsRegister(node),
853 g.UseRegister(next->InputAt(0)));
854 return;
855 case IrOpcode::kFloat32RoundTiesEven:
856 Emit(kMips64RoundWS, g.DefineAsRegister(node),
857 g.UseRegister(next->InputAt(0)));
858 return;
859 case IrOpcode::kFloat32RoundTruncate:
860 Emit(kMips64TruncWS, g.DefineAsRegister(node),
861 g.UseRegister(next->InputAt(0)));
862 return;
863 default:
864 Emit(kMips64TruncWS, g.DefineAsRegister(node),
865 g.UseRegister(value->InputAt(0)));
866 return;
867 }
868 } else {
869 // Match float32 -> float64 -> int32 representation change path.
870 Emit(kMips64TruncWS, g.DefineAsRegister(node),
871 g.UseRegister(value->InputAt(0)));
841 return; 872 return;
873 }
842 } 874 }
843 } 875 }
844 VisitRR(this, kMips64TruncWD, node); 876 VisitRR(this, kMips64TruncWD, node);
845 } 877 }
846 878
847 879
848 void InstructionSelector::VisitChangeFloat64ToUint32(Node* node) { 880 void InstructionSelector::VisitChangeFloat64ToUint32(Node* node) {
849 VisitRR(this, kMips64TruncUwD, node); 881 VisitRR(this, kMips64TruncUwD, node);
850 } 882 }
851 883
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
926 default: 958 default:
927 break; 959 break;
928 } 960 }
929 } 961 }
930 Emit(kMips64Ext, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)), 962 Emit(kMips64Ext, g.DefineAsRegister(node), g.UseRegister(node->InputAt(0)),
931 g.TempImmediate(0), g.TempImmediate(32)); 963 g.TempImmediate(0), g.TempImmediate(32));
932 } 964 }
933 965
934 966
935 void InstructionSelector::VisitTruncateFloat64ToFloat32(Node* node) { 967 void InstructionSelector::VisitTruncateFloat64ToFloat32(Node* node) {
968 Mips64OperandGenerator g(this);
969 Node* value = node->InputAt(0);
970 // Match TruncateFloat64ToFloat32(ChangeInt32ToFloat64) to corresponding
971 // instruction.
972 if (CanCover(node, value) &&
973 value->opcode() == IrOpcode::kChangeInt32ToFloat64) {
974 Emit(kMips64CvtSW, g.DefineAsRegister(node),
975 g.UseRegister(value->InputAt(0)));
976 return;
977 }
936 VisitRR(this, kMips64CvtSD, node); 978 VisitRR(this, kMips64CvtSD, node);
937 } 979 }
938 980
939 981
940 void InstructionSelector::VisitTruncateFloat64ToInt32(Node* node) { 982 void InstructionSelector::VisitTruncateFloat64ToInt32(Node* node) {
941 switch (TruncationModeOf(node->op())) { 983 switch (TruncationModeOf(node->op())) {
942 case TruncationMode::kJavaScript: 984 case TruncationMode::kJavaScript:
943 return VisitRR(this, kArchTruncateDoubleToI, node); 985 return VisitRR(this, kArchTruncateDoubleToI, node);
944 case TruncationMode::kRoundToZero: 986 case TruncationMode::kRoundToZero:
945 return VisitRR(this, kMips64TruncWD, node); 987 return VisitRR(this, kMips64TruncWD, node);
(...skipping 820 matching lines...) Expand 10 before | Expand all | Expand 10 after
1766 MachineOperatorBuilder::kFloat32RoundUp | 1808 MachineOperatorBuilder::kFloat32RoundUp |
1767 MachineOperatorBuilder::kFloat64RoundTruncate | 1809 MachineOperatorBuilder::kFloat64RoundTruncate |
1768 MachineOperatorBuilder::kFloat32RoundTruncate | 1810 MachineOperatorBuilder::kFloat32RoundTruncate |
1769 MachineOperatorBuilder::kFloat64RoundTiesEven | 1811 MachineOperatorBuilder::kFloat64RoundTiesEven |
1770 MachineOperatorBuilder::kFloat32RoundTiesEven; 1812 MachineOperatorBuilder::kFloat32RoundTiesEven;
1771 } 1813 }
1772 1814
1773 } // namespace compiler 1815 } // namespace compiler
1774 } // namespace internal 1816 } // namespace internal
1775 } // namespace v8 1817 } // namespace v8
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698