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

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

Issue 591343002: [turbofan] IA: support better left operand for commutative binops (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: addressed comments Created 6 years, 3 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 | Annotate | Revision Log
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | no next file » | 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/compiler/instruction-selector-unittest.h" 5 #include "src/compiler/instruction-selector-unittest.h"
6 6
7 namespace v8 { 7 namespace v8 {
8 namespace internal { 8 namespace internal {
9 namespace compiler { 9 namespace compiler {
10 10
(...skipping 22 matching lines...) Expand all
33 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithParameter) { 33 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithParameter) {
34 StreamBuilder m(this, kMachInt32, kMachInt64); 34 StreamBuilder m(this, kMachInt32, kMachInt64);
35 m.Return(m.TruncateInt64ToInt32(m.Parameter(0))); 35 m.Return(m.TruncateInt64ToInt32(m.Parameter(0)));
36 Stream s = m.Build(); 36 Stream s = m.Build();
37 ASSERT_EQ(1U, s.size()); 37 ASSERT_EQ(1U, s.size());
38 EXPECT_EQ(kX64Movl, s[0]->arch_opcode()); 38 EXPECT_EQ(kX64Movl, s[0]->arch_opcode());
39 } 39 }
40 40
41 41
42 // ----------------------------------------------------------------------------- 42 // -----------------------------------------------------------------------------
43 // Better left operand for commutative binops
44
45 TEST_F(InstructionSelectorTest, BetterLeftOperandTestAddBinop) {
46 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
47 Node* param1 = m.Parameter(0);
48 Node* param2 = m.Parameter(1);
49 Node* add = m.Int32Add(param1, param2);
50 m.Return(m.Int32Add(add, param1));
51 Stream s = m.Build();
52 ASSERT_EQ(2U, s.size());
53 EXPECT_EQ(kX64Add32, s[0]->arch_opcode());
54 ASSERT_EQ(2U, s[0]->InputCount());
55 ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated());
56 EXPECT_EQ(param2->id(), s.ToVreg(s[0]->InputAt(0)));
57 }
58
59
60 TEST_F(InstructionSelectorTest, BetterLeftOperandTestMulBinop) {
61 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
62 Node* param1 = m.Parameter(0);
63 Node* param2 = m.Parameter(1);
64 Node* mul = m.Int32Mul(param1, param2);
65 m.Return(m.Int32Mul(mul, param1));
66 Stream s = m.Build();
67 ASSERT_EQ(2U, s.size());
68 EXPECT_EQ(kX64Imul32, s[0]->arch_opcode());
69 ASSERT_EQ(2U, s[0]->InputCount());
70 ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated());
71 EXPECT_EQ(param2->id(), s.ToVreg(s[0]->InputAt(0)));
72 }
73
74
75 // -----------------------------------------------------------------------------
43 // Loads and stores 76 // Loads and stores
44 77
45 namespace { 78 namespace {
46 79
47 struct MemoryAccess { 80 struct MemoryAccess {
48 MachineType type; 81 MachineType type;
49 ArchOpcode load_opcode; 82 ArchOpcode load_opcode;
50 ArchOpcode store_opcode; 83 ArchOpcode store_opcode;
51 }; 84 };
52 85
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 } 135 }
103 136
104 137
105 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, 138 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
106 InstructionSelectorMemoryAccessTest, 139 InstructionSelectorMemoryAccessTest,
107 ::testing::ValuesIn(kMemoryAccesses)); 140 ::testing::ValuesIn(kMemoryAccesses));
108 141
109 } // namespace compiler 142 } // namespace compiler
110 } // namespace internal 143 } // namespace internal
111 } // namespace v8 144 } // namespace v8
OLDNEW
« no previous file with comments | « src/compiler/x64/instruction-selector-x64.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698