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

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

Issue 936323004: [x64] Improve instruction selection for TruncateInt64ToInt32. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 10 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 | « no previous file | test/unittests/compiler/x64/instruction-selector-x64-unittest.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 794 matching lines...) Expand 10 before | Expand all | Expand 10 after
805 X64OperandGenerator g(this); 805 X64OperandGenerator g(this);
806 Emit(kSSECvtsd2ss, g.DefineAsRegister(node), g.Use(node->InputAt(0))); 806 Emit(kSSECvtsd2ss, g.DefineAsRegister(node), g.Use(node->InputAt(0)));
807 } 807 }
808 808
809 809
810 void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) { 810 void InstructionSelector::VisitTruncateInt64ToInt32(Node* node) {
811 X64OperandGenerator g(this); 811 X64OperandGenerator g(this);
812 Node* value = node->InputAt(0); 812 Node* value = node->InputAt(0);
813 if (CanCover(node, value)) { 813 if (CanCover(node, value)) {
814 switch (value->opcode()) { 814 switch (value->opcode()) {
815 case IrOpcode::kWord64Sar: 815 case IrOpcode::kWord64Sar: {
816 case IrOpcode::kWord64Shr: {
817 Int64BinopMatcher m(value); 816 Int64BinopMatcher m(value);
818 if (m.right().Is(32)) { 817 if (m.right().IsInRange(1, 32)) {
819 Emit(kX64Shr, g.DefineSameAsFirst(node), 818 Emit(kX64Shr, g.DefineSameAsFirst(node),
820 g.UseRegister(m.left().node()), g.TempImmediate(32)); 819 g.UseRegister(m.left().node()),
820 g.UseImmediate(m.right().node()));
821 return; 821 return;
822 } 822 }
823 break; 823 break;
824 }
825 case IrOpcode::kWord64Shl: {
826 Int64BinopMatcher m(value);
827 if (m.right().IsInRange(1, 31)) {
828 Emit(kX64Shl32, g.DefineSameAsFirst(node),
829 g.UseRegister(m.left().node()),
830 g.UseImmediate(m.right().node()));
831 return;
832 }
833 break;
824 } 834 }
825 default: 835 default:
826 break; 836 break;
827 } 837 }
828 } 838 }
829 Emit(kX64Movl, g.DefineAsRegister(node), g.Use(value)); 839 // Otherwise truncation from 64-bit to 32-bit is a no-nop, as 32-bit
840 // operations just ignore the upper 64-bit.
841 Emit(kArchNop, g.DefineAsRegister(node), g.Use(value));
830 } 842 }
831 843
832 844
833 void InstructionSelector::VisitFloat64Add(Node* node) { 845 void InstructionSelector::VisitFloat64Add(Node* node) {
834 X64OperandGenerator g(this); 846 X64OperandGenerator g(this);
835 if (IsSupported(AVX)) { 847 if (IsSupported(AVX)) {
836 Emit(kAVXFloat64Add, g.DefineAsRegister(node), 848 Emit(kAVXFloat64Add, g.DefineAsRegister(node),
837 g.UseRegister(node->InputAt(0)), g.Use(node->InputAt(1))); 849 g.UseRegister(node->InputAt(0)), g.Use(node->InputAt(1)));
838 } else { 850 } else {
839 Emit(kSSEFloat64Add, g.DefineSameAsFirst(node), 851 Emit(kSSEFloat64Add, g.DefineSameAsFirst(node),
(...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after
1385 MachineOperatorBuilder::kFloat64Ceil | 1397 MachineOperatorBuilder::kFloat64Ceil |
1386 MachineOperatorBuilder::kFloat64RoundTruncate | 1398 MachineOperatorBuilder::kFloat64RoundTruncate |
1387 MachineOperatorBuilder::kWord32ShiftIsSafe; 1399 MachineOperatorBuilder::kWord32ShiftIsSafe;
1388 } 1400 }
1389 return MachineOperatorBuilder::kNoFlags; 1401 return MachineOperatorBuilder::kNoFlags;
1390 } 1402 }
1391 1403
1392 } // namespace compiler 1404 } // namespace compiler
1393 } // namespace internal 1405 } // namespace internal
1394 } // namespace v8 1406 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/unittests/compiler/x64/instruction-selector-x64-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698