| 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/generic-node-inl.h" | 10 #include "src/compiler/generic-node-inl.h" |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 } | 166 } |
| 167 break; | 167 break; |
| 168 } | 168 } |
| 169 case IrOpcode::kWord32Xor: { | 169 case IrOpcode::kWord32Xor: { |
| 170 Int32BinopMatcher m(node); | 170 Int32BinopMatcher m(node); |
| 171 if (m.right().Is(0)) return Replace(m.left().node()); // x ^ 0 => x | 171 if (m.right().Is(0)) return Replace(m.left().node()); // x ^ 0 => x |
| 172 if (m.IsFoldable()) { // K ^ K => K | 172 if (m.IsFoldable()) { // K ^ K => K |
| 173 return ReplaceInt32(m.left().Value() ^ m.right().Value()); | 173 return ReplaceInt32(m.left().Value() ^ m.right().Value()); |
| 174 } | 174 } |
| 175 if (m.LeftEqualsRight()) return ReplaceInt32(0); // x ^ x => 0 | 175 if (m.LeftEqualsRight()) return ReplaceInt32(0); // x ^ x => 0 |
| 176 if (m.left().IsWord32Xor() && m.right().Is(-1)) { |
| 177 Int32BinopMatcher mleft(m.left().node()); |
| 178 if (mleft.right().Is(-1)) { // (x ^ -1) ^ -1 => x |
| 179 return Replace(mleft.left().node()); |
| 180 } |
| 181 } |
| 176 break; | 182 break; |
| 177 } | 183 } |
| 178 case IrOpcode::kWord32Shl: { | 184 case IrOpcode::kWord32Shl: { |
| 179 Int32BinopMatcher m(node); | 185 Int32BinopMatcher m(node); |
| 180 if (m.right().Is(0)) return Replace(m.left().node()); // x << 0 => x | 186 if (m.right().Is(0)) return Replace(m.left().node()); // x << 0 => x |
| 181 if (m.IsFoldable()) { // K << K => K | 187 if (m.IsFoldable()) { // K << K => K |
| 182 return ReplaceInt32(m.left().Value() << m.right().Value()); | 188 return ReplaceInt32(m.left().Value() << m.right().Value()); |
| 183 } | 189 } |
| 184 if (m.right().IsInRange(1, 31)) { | 190 if (m.right().IsInRange(1, 31)) { |
| 185 // (x >>> K) << K => x & ~(2^K - 1) | 191 // (x >>> K) << K => x & ~(2^K - 1) |
| (...skipping 477 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 663 MachineOperatorBuilder* MachineOperatorReducer::machine() const { | 669 MachineOperatorBuilder* MachineOperatorReducer::machine() const { |
| 664 return jsgraph()->machine(); | 670 return jsgraph()->machine(); |
| 665 } | 671 } |
| 666 | 672 |
| 667 | 673 |
| 668 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } | 674 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } |
| 669 | 675 |
| 670 } // namespace compiler | 676 } // namespace compiler |
| 671 } // namespace internal | 677 } // namespace internal |
| 672 } // namespace v8 | 678 } // namespace v8 |
| OLD | NEW |