Index: src/compiler/mips/instruction-selector-mips.cc |
diff --git a/src/compiler/mips/instruction-selector-mips.cc b/src/compiler/mips/instruction-selector-mips.cc |
index 8d1631dfa2825e94db192f85d3418c3fcc2641cb..1ab782a60bbd575960c2e0c3eb702fa56f1af891 100644 |
--- a/src/compiler/mips/instruction-selector-mips.cc |
+++ b/src/compiler/mips/instruction-selector-mips.cc |
@@ -330,6 +330,30 @@ void InstructionSelector::VisitWord32Xor(Node* node) { |
void InstructionSelector::VisitWord32Shl(Node* node) { |
+ 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.
|
+ if (m.left().IsWord32And() && CanCover(node, m.left().node()) && |
+ m.right().IsInRange(1, 31)) { |
+ MipsOperandGenerator g(this); |
+ Int32BinopMatcher mleft(m.left().node()); |
+ if (mleft.right().HasValue()) { |
+ uint32_t mask = mleft.right().Value(); |
+ uint32_t mask_width = base::bits::CountPopulation32(mask); |
+ uint32_t mask_msb = base::bits::CountLeadingZeros32(mask); |
+ if ((mask_width != 0) && (mask_msb + mask_width == 32)) { |
+ uint32_t shift = m.right().Value(); |
+ DCHECK_EQ(0u, base::bits::CountTrailingZeros32(mask)); |
+ DCHECK_NE(0u, shift); |
+ if ((shift + mask_width) >= 32) { |
+ // If the mask is contiguous and reaches or extends beyond the top |
+ // bit, only the shift is needed. |
+ Emit(kMipsShl, g.DefineAsRegister(node), |
+ g.UseRegister(mleft.left().node()), |
+ g.UseImmediate(m.right().node())); |
+ return; |
+ } |
+ } |
+ } |
+ } |
VisitRRO(this, kMipsShl, node); |
} |