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

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

Issue 928723003: Revert of [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 | « 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 "test/unittests/compiler/instruction-selector-unittest.h" 5 #include "test/unittests/compiler/instruction-selector-unittest.h"
6 6
7 #include "src/compiler/node-matchers.h" 7 #include "src/compiler/node-matchers.h"
8 8
9 namespace v8 { 9 namespace v8 {
10 namespace internal { 10 namespace internal {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 StreamBuilder m(this, kMachFloat64, kMachFloat32); 56 StreamBuilder m(this, kMachFloat64, kMachFloat32);
57 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0))); 57 m.Return(m.TruncateFloat64ToFloat32(m.Parameter(0)));
58 Stream s = m.Build(); 58 Stream s = m.Build();
59 ASSERT_EQ(1U, s.size()); 59 ASSERT_EQ(1U, s.size());
60 EXPECT_EQ(kSSECvtsd2ss, s[0]->arch_opcode()); 60 EXPECT_EQ(kSSECvtsd2ss, s[0]->arch_opcode());
61 EXPECT_EQ(1U, s[0]->InputCount()); 61 EXPECT_EQ(1U, s[0]->InputCount());
62 EXPECT_EQ(1U, s[0]->OutputCount()); 62 EXPECT_EQ(1U, s[0]->OutputCount());
63 } 63 }
64 64
65 65
66 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithParameter) {
67 StreamBuilder m(this, kMachInt32, kMachInt64);
68 m.Return(m.TruncateInt64ToInt32(m.Parameter(0)));
69 Stream s = m.Build();
70 ASSERT_EQ(1U, s.size());
71 EXPECT_EQ(kX64Movl, s[0]->arch_opcode());
72 }
73
74
66 // ----------------------------------------------------------------------------- 75 // -----------------------------------------------------------------------------
67 // Loads and stores 76 // Loads and stores
68 77
69 namespace { 78 namespace {
70 79
71 struct MemoryAccess { 80 struct MemoryAccess {
72 MachineType type; 81 MachineType type;
73 ArchOpcode load_opcode; 82 ArchOpcode load_opcode;
74 ArchOpcode store_opcode; 83 ArchOpcode store_opcode;
75 }; 84 };
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 199
191 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest, 200 INSTANTIATE_TEST_CASE_P(InstructionSelectorTest,
192 InstructionSelectorChangeUint32ToUint64Test, 201 InstructionSelectorChangeUint32ToUint64Test,
193 ::testing::ValuesIn(kWord32BinaryOperations)); 202 ::testing::ValuesIn(kWord32BinaryOperations));
194 203
195 204
196 // ----------------------------------------------------------------------------- 205 // -----------------------------------------------------------------------------
197 // TruncateInt64ToInt32. 206 // TruncateInt64ToInt32.
198 207
199 208
200 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithParameter) { 209 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Sar) {
201 StreamBuilder m(this, kMachInt32, kMachInt64); 210 StreamBuilder m(this, kMachInt32, kMachInt64);
202 m.Return(m.TruncateInt64ToInt32(m.Parameter(0))); 211 Node* const p = m.Parameter(0);
212 Node* const t = m.TruncateInt64ToInt32(m.Word64Sar(p, m.Int64Constant(32)));
213 m.Return(t);
203 Stream s = m.Build(); 214 Stream s = m.Build();
204 ASSERT_EQ(0U, s.size()); 215 ASSERT_EQ(1U, s.size());
216 EXPECT_EQ(kX64Shr, s[0]->arch_opcode());
217 ASSERT_EQ(2U, s[0]->InputCount());
218 EXPECT_EQ(s.ToVreg(p), s.ToVreg(s[0]->InputAt(0)));
219 EXPECT_EQ(32, s.ToInt32(s[0]->InputAt(1)));
220 ASSERT_EQ(1U, s[0]->OutputCount());
221 EXPECT_TRUE(s.IsSameAsFirst(s[0]->OutputAt(0)));
222 EXPECT_EQ(s.ToVreg(t), s.ToVreg(s[0]->OutputAt(0)));
205 } 223 }
206 224
207 225
208 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Sar) { 226 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Shr) {
209 TRACED_FORRANGE(int32_t, k, 1, 32) { 227 StreamBuilder m(this, kMachInt32, kMachInt64);
210 StreamBuilder m(this, kMachInt32, kMachInt64); 228 Node* const p = m.Parameter(0);
211 Node* const p = m.Parameter(0); 229 Node* const t = m.TruncateInt64ToInt32(m.Word64Shr(p, m.Int64Constant(32)));
212 Node* const t = m.TruncateInt64ToInt32(m.Word64Sar(p, m.Int64Constant(k))); 230 m.Return(t);
213 m.Return(t); 231 Stream s = m.Build();
214 Stream s = m.Build(); 232 ASSERT_EQ(1U, s.size());
215 ASSERT_EQ(1U, s.size()); 233 EXPECT_EQ(kX64Shr, s[0]->arch_opcode());
216 EXPECT_EQ(kX64Shr, s[0]->arch_opcode()); 234 ASSERT_EQ(2U, s[0]->InputCount());
217 ASSERT_EQ(2U, s[0]->InputCount()); 235 EXPECT_EQ(s.ToVreg(p), s.ToVreg(s[0]->InputAt(0)));
218 EXPECT_EQ(s.ToVreg(p), s.ToVreg(s[0]->InputAt(0))); 236 EXPECT_EQ(32, s.ToInt32(s[0]->InputAt(1)));
219 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(1))); 237 ASSERT_EQ(1U, s[0]->OutputCount());
220 ASSERT_EQ(1U, s[0]->OutputCount()); 238 EXPECT_TRUE(s.IsSameAsFirst(s[0]->OutputAt(0)));
221 EXPECT_TRUE(s.IsSameAsFirst(s[0]->OutputAt(0))); 239 EXPECT_EQ(s.ToVreg(t), s.ToVreg(s[0]->OutputAt(0)));
222 EXPECT_EQ(s.ToVreg(t), s.ToVreg(s[0]->OutputAt(0)));
223 }
224 } 240 }
225 241
226 242
227 TEST_F(InstructionSelectorTest, TruncateInt64ToInt32WithWord64Shl) {
228 TRACED_FORRANGE(int32_t, k, 1, 31) {
229 StreamBuilder m(this, kMachInt32, kMachInt64);
230 Node* const p = m.Parameter(0);
231 Node* const t = m.TruncateInt64ToInt32(m.Word64Shl(p, m.Int64Constant(k)));
232 m.Return(t);
233 Stream s = m.Build();
234 ASSERT_EQ(1U, s.size());
235 EXPECT_EQ(kX64Shl32, s[0]->arch_opcode());
236 ASSERT_EQ(2U, s[0]->InputCount());
237 EXPECT_EQ(s.ToVreg(p), s.ToVreg(s[0]->InputAt(0)));
238 EXPECT_EQ(k, s.ToInt32(s[0]->InputAt(1)));
239 ASSERT_EQ(1U, s[0]->OutputCount());
240 EXPECT_TRUE(s.IsSameAsFirst(s[0]->OutputAt(0)));
241 EXPECT_EQ(s.ToVreg(t), s.ToVreg(s[0]->OutputAt(0)));
242 }
243 }
244
245
246 // ----------------------------------------------------------------------------- 243 // -----------------------------------------------------------------------------
247 // Addition. 244 // Addition.
248 245
249 246
250 TEST_F(InstructionSelectorTest, Int32AddWithInt32ParametersLea) { 247 TEST_F(InstructionSelectorTest, Int32AddWithInt32ParametersLea) {
251 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32); 248 StreamBuilder m(this, kMachInt32, kMachInt32, kMachInt32);
252 Node* const p0 = m.Parameter(0); 249 Node* const p0 = m.Parameter(0);
253 Node* const p1 = m.Parameter(1); 250 Node* const p1 = m.Parameter(1);
254 Node* const a0 = m.Int32Add(p0, p1); 251 Node* const a0 = m.Int32Add(p0, p1);
255 // Additional uses of input to add chooses lea 252 // Additional uses of input to add chooses lea
(...skipping 870 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 ASSERT_EQ(1U, s[0]->InputCount()); 1123 ASSERT_EQ(1U, s[0]->InputCount());
1127 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0))); 1124 EXPECT_EQ(s.ToVreg(p0), s.ToVreg(s[0]->InputAt(0)));
1128 ASSERT_EQ(1U, s[0]->OutputCount()); 1125 ASSERT_EQ(1U, s[0]->OutputCount());
1129 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output())); 1126 EXPECT_EQ(s.ToVreg(n), s.ToVreg(s[0]->Output()));
1130 } 1127 }
1131 } 1128 }
1132 1129
1133 } // namespace compiler 1130 } // namespace compiler
1134 } // namespace internal 1131 } // namespace internal
1135 } // namespace v8 1132 } // 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