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/compiler/machine-operator-reducer.h" | 5 #include "src/compiler/machine-operator-reducer.h" |
6 | 6 |
7 #include "src/base/bits.h" | 7 #include "src/base/bits.h" |
8 #include "src/base/division-by-constant.h" | 8 #include "src/base/division-by-constant.h" |
9 #include "src/codegen.h" | 9 #include "src/codegen.h" |
10 #include "src/compiler/diamond.h" | 10 #include "src/compiler/diamond.h" |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
130 if (m.LeftEqualsRight()) return Replace(m.left().node()); // x & x => x | 130 if (m.LeftEqualsRight()) return Replace(m.left().node()); // x & x => x |
131 if (m.left().IsWord32And() && m.right().HasValue()) { | 131 if (m.left().IsWord32And() && m.right().HasValue()) { |
132 Int32BinopMatcher mleft(m.left().node()); | 132 Int32BinopMatcher mleft(m.left().node()); |
133 if (mleft.right().HasValue()) { // (x & K) & K => x & K | 133 if (mleft.right().HasValue()) { // (x & K) & K => x & K |
134 node->ReplaceInput(0, mleft.left().node()); | 134 node->ReplaceInput(0, mleft.left().node()); |
135 node->ReplaceInput( | 135 node->ReplaceInput( |
136 1, Int32Constant(m.right().Value() & mleft.right().Value())); | 136 1, Int32Constant(m.right().Value() & mleft.right().Value())); |
137 return Changed(node); | 137 return Changed(node); |
138 } | 138 } |
139 } | 139 } |
140 if (m.left().IsInt32Add() && m.right().IsNegativePowerOf2()) { | |
141 Int32BinopMatcher mleft(m.left().node()); | |
142 if (mleft.right().HasValue() && | |
143 (mleft.right().Value() & m.right().Value()) == | |
144 mleft.right().Value()) { | |
145 // (x + K) & K => (x & K) + K | |
Jarin
2014/11/24 12:28:09
How about (x + K1) & K2 => (x & K2) + K1?
Benedikt Meurer
2014/11/24 12:29:33
This was the terminology that we always used here.
| |
146 return Replace(graph()->NewNode( | |
147 machine()->Int32Add(), | |
148 graph()->NewNode(machine()->Word32And(), mleft.left().node(), | |
149 m.right().node()), | |
150 mleft.right().node())); | |
Jarin
2014/11/24 12:28:09
Funny indentation.
Benedikt Meurer
2014/11/24 12:29:33
clang-format...
| |
151 } | |
152 } | |
140 break; | 153 break; |
141 } | 154 } |
142 case IrOpcode::kWord32Or: { | 155 case IrOpcode::kWord32Or: { |
143 Int32BinopMatcher m(node); | 156 Int32BinopMatcher m(node); |
144 if (m.right().Is(0)) return Replace(m.left().node()); // x | 0 => x | 157 if (m.right().Is(0)) return Replace(m.left().node()); // x | 0 => x |
145 if (m.right().Is(-1)) return Replace(m.right().node()); // x | -1 => -1 | 158 if (m.right().Is(-1)) return Replace(m.right().node()); // x | -1 => -1 |
146 if (m.IsFoldable()) { // K | K => K | 159 if (m.IsFoldable()) { // K | K => K |
147 return ReplaceInt32(m.left().Value() | m.right().Value()); | 160 return ReplaceInt32(m.left().Value() | m.right().Value()); |
148 } | 161 } |
149 if (m.LeftEqualsRight()) return Replace(m.left().node()); // x | x => x | 162 if (m.LeftEqualsRight()) return Replace(m.left().node()); // x | x => x |
(...skipping 686 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
836 MachineOperatorBuilder* MachineOperatorReducer::machine() const { | 849 MachineOperatorBuilder* MachineOperatorReducer::machine() const { |
837 return jsgraph()->machine(); | 850 return jsgraph()->machine(); |
838 } | 851 } |
839 | 852 |
840 | 853 |
841 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } | 854 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } |
842 | 855 |
843 } // namespace compiler | 856 } // namespace compiler |
844 } // namespace internal | 857 } // namespace internal |
845 } // namespace v8 | 858 } // namespace v8 |
OLD | NEW |