Index: src/compiler/machine-operator-reducer.cc |
diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc |
index 836ddd146483d4702aa7c2bfb76b158bbf504a5f..f51125a001b660d02a5cfbc9e6577acc699a75b8 100644 |
--- a/src/compiler/machine-operator-reducer.cc |
+++ b/src/compiler/machine-operator-reducer.cc |
@@ -534,22 +534,8 @@ Reduction MachineOperatorReducer::Reduce(Node* node) { |
if (m.IsChangeFloat32ToFloat64()) return Replace(m.node()->InputAt(0)); |
break; |
} |
- case IrOpcode::kStore: { |
- Node* const value = node->InputAt(2); |
- // TODO(turbofan): Extend to 64-bit? |
- if (value->opcode() == IrOpcode::kWord32And) { |
- MachineType const rep = static_cast<MachineType>( |
- StoreRepresentationOf(node->op()).machine_type() & kRepMask); |
- Uint32BinopMatcher m(value); |
- if (m.right().HasValue() && |
- ((rep == kRepWord8 && (m.right().Value() & 0xff) == 0xff) || |
- (rep == kRepWord16 && (m.right().Value() & 0xffff) == 0xffff))) { |
- node->ReplaceInput(2, m.left().node()); |
- return Changed(node); |
- } |
- } |
- break; |
- } |
+ case IrOpcode::kStore: |
+ return ReduceStore(node); |
default: |
break; |
} |
@@ -712,6 +698,41 @@ Reduction MachineOperatorReducer::ReduceUint32Mod(Node* node) { |
} |
+Reduction MachineOperatorReducer::ReduceStore(Node* node) { |
+ MachineType const rep = |
+ RepresentationOf(StoreRepresentationOf(node->op()).machine_type()); |
+ Node* const value = node->InputAt(2); |
+ switch (value->opcode()) { |
+ case IrOpcode::kWord32And: { |
+ Uint32BinopMatcher m(value); |
+ if (m.right().HasValue() && |
+ ((rep == kRepWord8 && (m.right().Value() & 0xff) == 0xff) || |
+ (rep == kRepWord16 && (m.right().Value() & 0xffff) == 0xffff))) { |
+ node->ReplaceInput(2, m.left().node()); |
+ return Changed(node); |
+ } |
+ break; |
+ } |
+ case IrOpcode::kWord32Sar: { |
+ Int32BinopMatcher m(value); |
+ if (m.left().IsWord32Shl() && |
+ ((rep == kRepWord8 && m.right().IsInRange(1, 24)) || |
+ (rep == kRepWord16 && m.right().IsInRange(1, 16)))) { |
+ Int32BinopMatcher mleft(m.left().node()); |
+ if (mleft.right().Is(m.right().Value())) { |
+ node->ReplaceInput(2, mleft.left().node()); |
+ return Changed(node); |
+ } |
+ } |
+ break; |
+ } |
+ default: |
+ break; |
+ } |
+ return NoChange(); |
+} |
+ |
+ |
Reduction MachineOperatorReducer::ReduceProjection(size_t index, Node* node) { |
switch (node->opcode()) { |
case IrOpcode::kInt32AddWithOverflow: { |