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

Side by Side Diff: test/unittests/compiler/ia32/instruction-selector-ia32-unittest.cc

Issue 654833002: [turbofan] Optimize division/modulus by constant. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 6 years, 2 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
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 "test/unittests/compiler/instruction-selector-unittest.h" 5 #include "test/unittests/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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 ASSERT_EQ(1U, s.size()); 96 ASSERT_EQ(1U, s.size());
97 EXPECT_EQ(kSSECvtsd2ss, s[0]->arch_opcode()); 97 EXPECT_EQ(kSSECvtsd2ss, s[0]->arch_opcode());
98 EXPECT_EQ(1U, s[0]->InputCount()); 98 EXPECT_EQ(1U, s[0]->InputCount());
99 EXPECT_EQ(1U, s[0]->OutputCount()); 99 EXPECT_EQ(1U, s[0]->OutputCount());
100 } 100 }
101 101
102 102
103 // ----------------------------------------------------------------------------- 103 // -----------------------------------------------------------------------------
104 // Better left operand for commutative binops 104 // Better left operand for commutative binops
105 105
106
106 TEST_F(InstructionSelectorTest, BetterLeftOperandTestAddBinop) { 107 TEST_F(InstructionSelectorTest, BetterLeftOperandTestAddBinop) {
107 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 108 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
108 Node* param1 = m.Parameter(0); 109 Node* param1 = m.Parameter(0);
109 Node* param2 = m.Parameter(1); 110 Node* param2 = m.Parameter(1);
110 Node* add = m.Int32Add(param1, param2); 111 Node* add = m.Int32Add(param1, param2);
111 m.Return(m.Int32Add(add, param1)); 112 m.Return(m.Int32Add(add, param1));
112 Stream s = m.Build(); 113 Stream s = m.Build();
113 ASSERT_EQ(2U, s.size()); 114 ASSERT_EQ(2U, s.size());
114 EXPECT_EQ(kIA32Add, s[0]->arch_opcode()); 115 EXPECT_EQ(kIA32Add, s[0]->arch_opcode());
115 ASSERT_EQ(2U, s[0]->InputCount()); 116 ASSERT_EQ(2U, s[0]->InputCount());
(...skipping 13 matching lines...) Expand all
129 EXPECT_EQ(kIA32Imul, s[0]->arch_opcode()); 130 EXPECT_EQ(kIA32Imul, s[0]->arch_opcode());
130 ASSERT_EQ(2U, s[0]->InputCount()); 131 ASSERT_EQ(2U, s[0]->InputCount());
131 ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated()); 132 ASSERT_TRUE(s[0]->InputAt(0)->IsUnallocated());
132 EXPECT_EQ(s.ToVreg(param2), s.ToVreg(s[0]->InputAt(0))); 133 EXPECT_EQ(s.ToVreg(param2), s.ToVreg(s[0]->InputAt(0)));
133 } 134 }
134 135
135 136
136 // ----------------------------------------------------------------------------- 137 // -----------------------------------------------------------------------------
137 // Conversions. 138 // Conversions.
138 139
140
139 TEST_F(InstructionSelectorTest, ChangeUint32ToFloat64WithParameter) { 141 TEST_F(InstructionSelectorTest, ChangeUint32ToFloat64WithParameter) {
140 StreamBuilder m(this, kMachFloat64, kMachUint32); 142 StreamBuilder m(this, kMachFloat64, kMachUint32);
141 m.Return(m.ChangeUint32ToFloat64(m.Parameter(0))); 143 m.Return(m.ChangeUint32ToFloat64(m.Parameter(0)));
142 Stream s = m.Build(); 144 Stream s = m.Build();
143 ASSERT_EQ(1U, s.size()); 145 ASSERT_EQ(1U, s.size());
144 EXPECT_EQ(kSSEUint32ToFloat64, s[0]->arch_opcode()); 146 EXPECT_EQ(kSSEUint32ToFloat64, s[0]->arch_opcode());
145 } 147 }
146 148
147 149
148 // ----------------------------------------------------------------------------- 150 // -----------------------------------------------------------------------------
149 // Loads and stores 151 // Loads and stores
150 152
153
151 namespace { 154 namespace {
152 155
153 struct MemoryAccess { 156 struct MemoryAccess {
154 MachineType type; 157 MachineType type;
155 ArchOpcode load_opcode; 158 ArchOpcode load_opcode;
156 ArchOpcode store_opcode; 159 ArchOpcode store_opcode;
157 }; 160 };
158 161
159 162
160 std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) { 163 std::ostream& operator<<(std::ostream& os, const MemoryAccess& memacc) {
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
288 291
289 292
290 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, 293 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
291 InstructionSelectorMemoryAccessTest, 294 InstructionSelectorMemoryAccessTest,
292 ::testing::ValuesIn(kMemoryAccesses)); 295 ::testing::ValuesIn(kMemoryAccesses));
293 296
294 297
295 // ----------------------------------------------------------------------------- 298 // -----------------------------------------------------------------------------
296 // AddressingMode for loads and stores. 299 // AddressingMode for loads and stores.
297 300
301
298 class AddressingModeUnitTest : public InstructionSelectorTest { 302 class AddressingModeUnitTest : public InstructionSelectorTest {
299 public: 303 public:
300 AddressingModeUnitTest() : m(NULL) { Reset(); } 304 AddressingModeUnitTest() : m(NULL) { Reset(); }
301 ~AddressingModeUnitTest() { delete m; } 305 ~AddressingModeUnitTest() { delete m; }
302 306
303 void Run(Node* base, Node* index, AddressingMode mode) { 307 void Run(Node* base, Node* index, AddressingMode mode) {
304 Node* load = m->Load(kMachInt32, base, index); 308 Node* load = m->Load(kMachInt32, base, index);
305 m->Store(kMachInt32, base, index, load); 309 m->Store(kMachInt32, base, index, load);
306 m->Return(m->Int32Constant(0)); 310 m->Return(m->Int32Constant(0));
307 Stream s = m->Build(); 311 Stream s = m->Build();
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
431 Node* index = indices[j]; 435 Node* index = indices[j];
432 Run(base, index, kMode_MI); 436 Run(base, index, kMode_MI);
433 } 437 }
434 } 438 }
435 } 439 }
436 440
437 441
438 // ----------------------------------------------------------------------------- 442 // -----------------------------------------------------------------------------
439 // Multiplication. 443 // Multiplication.
440 444
445
441 namespace { 446 namespace {
442 447
443 struct MultParam { 448 struct MultParam {
444 int value; 449 int value;
445 bool lea_expected; 450 bool lea_expected;
446 AddressingMode addressing_mode; 451 AddressingMode addressing_mode;
447 }; 452 };
448 453
449 454
450 std::ostream& operator<<(std::ostream& os, const MultParam& m) { 455 std::ostream& operator<<(std::ostream& os, const MultParam& m) {
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
569 EXPECT_EQ(kIA32Imul, s[0]->arch_opcode()); 574 EXPECT_EQ(kIA32Imul, s[0]->arch_opcode());
570 EXPECT_EQ(kIA32Add, s[1]->arch_opcode()); 575 EXPECT_EQ(kIA32Add, s[1]->arch_opcode());
571 } 576 }
572 } 577 }
573 } 578 }
574 579
575 580
576 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorMultTest, 581 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, InstructionSelectorMultTest,
577 ::testing::ValuesIn(kMultParams)); 582 ::testing::ValuesIn(kMultParams));
578 583
584
585 TEST_F(InstructionSelectorTest, Int32MulHigh) {
586 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
587 Node* const p0 = m.Parameter(0);
588 Node* const p1 = m.Parameter(1);
589 Node* const n = m.Int32MulHigh(p0, p1);
590 m.Return(n);
591 Stream s = m.Build();
592 ASSERT_EQ(1U, s.size());
593 EXPECT_EQ(kIA32ImulHigh, s[0]->arch_opcode());
594 ASSERT_EQ(2U, s[0]->InputCount());
595 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
596 EXPECT_EQ(s.ToVreg(p1), s.ToVreg(s[0]->InputAt(1)));
597 ASSERT_EQ(1U, s[0]->OutputCount());
598 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
599 }
600
579 } // namespace compiler 601 } // namespace compiler
580 } // namespace internal 602 } // namespace internal
581 } // namespace v8 603 } // namespace v8
OLDNEW
« no previous file with comments | « test/unittests/compiler/graph-unittest.cc ('k') | test/unittests/compiler/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698