Chromium Code Reviews

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

Issue 1496013003: MIPS:[turbofan] Match shift left and bitwise And with mask when possible. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Fix typo. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View unified diff |
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 312 matching lines...)
323 MipsOperandGenerator g(this); 323 MipsOperandGenerator g(this);
324 Emit(kMipsNor, g.DefineAsRegister(node), g.UseRegister(m.left().node()), 324 Emit(kMipsNor, g.DefineAsRegister(node), g.UseRegister(m.left().node()),
325 g.TempImmediate(0)); 325 g.TempImmediate(0));
326 return; 326 return;
327 } 327 }
328 VisitBinop(this, node, kMipsXor); 328 VisitBinop(this, node, kMipsXor);
329 } 329 }
330 330
331 331
332 void InstructionSelector::VisitWord32Shl(Node* node) { 332 void InstructionSelector::VisitWord32Shl(Node* node) {
333 Int32BinopMatcher m(node);
titzer 2015/12/04 09:26:58 Can we get a comment that illustrates the pattern
dusan.milosavljevic 2015/12/04 12:50:58 Done.
334 if (m.left().IsWord32And() && CanCover(node, m.left().node()) &&
335 m.right().IsInRange(1, 31)) {
336 MipsOperandGenerator g(this);
337 Int32BinopMatcher mleft(m.left().node());
338 if (mleft.right().HasValue()) {
339 uint32_t mask = mleft.right().Value();
340 uint32_t mask_width = base::bits::CountPopulation32(mask);
341 uint32_t mask_msb = base::bits::CountLeadingZeros32(mask);
342 if ((mask_width != 0) && (mask_msb + mask_width == 32)) {
343 uint32_t shift = m.right().Value();
344 DCHECK_EQ(0u, base::bits::CountTrailingZeros32(mask));
345 DCHECK_NE(0u, shift);
346 if ((shift + mask_width) >= 32) {
347 // If the mask is contiguous and reaches or extends beyond the top
348 // bit, only the shift is needed.
349 Emit(kMipsShl, g.DefineAsRegister(node),
350 g.UseRegister(mleft.left().node()),
351 g.UseImmediate(m.right().node()));
352 return;
353 }
354 }
355 }
356 }
333 VisitRRO(this, kMipsShl, node); 357 VisitRRO(this, kMipsShl, node);
334 } 358 }
335 359
336 360
337 void InstructionSelector::VisitWord32Shr(Node* node) { 361 void InstructionSelector::VisitWord32Shr(Node* node) {
338 Int32BinopMatcher m(node); 362 Int32BinopMatcher m(node);
339 if (m.left().IsWord32And() && m.right().HasValue()) { 363 if (m.left().IsWord32And() && m.right().HasValue()) {
340 uint32_t lsb = m.right().Value() & 0x1f; 364 uint32_t lsb = m.right().Value() & 0x1f;
341 Int32BinopMatcher mleft(m.left().node()); 365 Int32BinopMatcher mleft(m.left().node());
342 if (mleft.right().HasValue()) { 366 if (mleft.right().HasValue()) {
(...skipping 883 matching lines...)
1226 MachineOperatorBuilder::kFloat32Max | 1250 MachineOperatorBuilder::kFloat32Max |
1227 MachineOperatorBuilder::kFloat32RoundDown | 1251 MachineOperatorBuilder::kFloat32RoundDown |
1228 MachineOperatorBuilder::kFloat32RoundUp | 1252 MachineOperatorBuilder::kFloat32RoundUp |
1229 MachineOperatorBuilder::kFloat32RoundTruncate | 1253 MachineOperatorBuilder::kFloat32RoundTruncate |
1230 MachineOperatorBuilder::kFloat32RoundTiesEven; 1254 MachineOperatorBuilder::kFloat32RoundTiesEven;
1231 } 1255 }
1232 1256
1233 } // namespace compiler 1257 } // namespace compiler
1234 } // namespace internal 1258 } // namespace internal
1235 } // namespace v8 1259 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/mips64/instruction-selector-mips64.cc » ('j') | src/compiler/mips64/instruction-selector-mips64.cc » ('J')

Powered by Google App Engine