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 80079c2ef663fc4b1c8ec1e32010c0fa963301a9..53a01d77e229083c2eff6eb525240955b93e20e2 100644 |
--- a/src/compiler/mips/instruction-selector-mips.cc |
+++ b/src/compiler/mips/instruction-selector-mips.cc |
@@ -284,6 +284,18 @@ void InstructionSelector::VisitWord32And(Node* node) { |
// Other cases fall through to the normal And operation. |
} |
} |
+ if (m.right().HasValue()) { |
+ uint32_t mask = m.right().Value(); |
+ uint32_t shift = base::bits::CountPopulation32(~mask); |
+ uint32_t msb = base::bits::CountLeadingZeros32(~mask); |
+ if (shift != 0 && shift != 32 && msb + shift == 32) { |
+ // Insert zeros for (x >> K) << K => x & ~(2^K - 1) expression reduction |
+ // and remove constant loading of invereted mask. |
+ Emit(kMipsIns, g.DefineSameAsFirst(node), g.UseRegister(m.left().node()), |
+ g.TempImmediate(0), g.TempImmediate(shift)); |
+ return; |
+ } |
+ } |
VisitBinop(this, node, kMipsAnd); |
} |