OLD | NEW |
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 480 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
491 } | 491 } |
492 VisitRRO(this, kMipsShl, node); | 492 VisitRRO(this, kMipsShl, node); |
493 } | 493 } |
494 | 494 |
495 | 495 |
496 void InstructionSelector::VisitWord32Shr(Node* node) { | 496 void InstructionSelector::VisitWord32Shr(Node* node) { |
497 Int32BinopMatcher m(node); | 497 Int32BinopMatcher m(node); |
498 if (m.left().IsWord32And() && m.right().HasValue()) { | 498 if (m.left().IsWord32And() && m.right().HasValue()) { |
499 uint32_t lsb = m.right().Value() & 0x1f; | 499 uint32_t lsb = m.right().Value() & 0x1f; |
500 Int32BinopMatcher mleft(m.left().node()); | 500 Int32BinopMatcher mleft(m.left().node()); |
501 if (mleft.right().HasValue()) { | 501 if (mleft.right().HasValue() && mleft.right().Value() != 0) { |
502 // Select Ext for Shr(And(x, mask), imm) where the result of the mask is | 502 // Select Ext for Shr(And(x, mask), imm) where the result of the mask is |
503 // shifted into the least-significant bits. | 503 // shifted into the least-significant bits. |
504 uint32_t mask = (mleft.right().Value() >> lsb) << lsb; | 504 uint32_t mask = (mleft.right().Value() >> lsb) << lsb; |
505 unsigned mask_width = base::bits::CountPopulation32(mask); | 505 unsigned mask_width = base::bits::CountPopulation32(mask); |
506 unsigned mask_msb = base::bits::CountLeadingZeros32(mask); | 506 unsigned mask_msb = base::bits::CountLeadingZeros32(mask); |
507 if ((mask_msb + mask_width + lsb) == 32) { | 507 if ((mask_msb + mask_width + lsb) == 32) { |
508 MipsOperandGenerator g(this); | 508 MipsOperandGenerator g(this); |
509 DCHECK_EQ(lsb, base::bits::CountTrailingZeros32(mask)); | 509 DCHECK_EQ(lsb, base::bits::CountTrailingZeros32(mask)); |
510 Emit(kMipsExt, g.DefineAsRegister(node), | 510 Emit(kMipsExt, g.DefineAsRegister(node), |
511 g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), | 511 g.UseRegister(mleft.left().node()), g.TempImmediate(lsb), |
(...skipping 1414 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1926 DCHECK(IsMipsArchVariant(kLoongson) || IsMipsArchVariant(kMips32r1) || | 1926 DCHECK(IsMipsArchVariant(kLoongson) || IsMipsArchVariant(kMips32r1) || |
1927 IsMipsArchVariant(kMips32r2)); | 1927 IsMipsArchVariant(kMips32r2)); |
1928 return MachineOperatorBuilder::AlignmentRequirements:: | 1928 return MachineOperatorBuilder::AlignmentRequirements:: |
1929 NoUnalignedAccessSupport(); | 1929 NoUnalignedAccessSupport(); |
1930 } | 1930 } |
1931 } | 1931 } |
1932 | 1932 |
1933 } // namespace compiler | 1933 } // namespace compiler |
1934 } // namespace internal | 1934 } // namespace internal |
1935 } // namespace v8 | 1935 } // namespace v8 |
OLD | NEW |