| 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 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 236 if (m.left().IsInt32Sub() && m.right().Is(0)) { // x - y == 0 => x == y | 236 if (m.left().IsInt32Sub() && m.right().Is(0)) { // x - y == 0 => x == y |
| 237 Int32BinopMatcher msub(m.left().node()); | 237 Int32BinopMatcher msub(m.left().node()); |
| 238 node->ReplaceInput(0, msub.left().node()); | 238 node->ReplaceInput(0, msub.left().node()); |
| 239 node->ReplaceInput(1, msub.right().node()); | 239 node->ReplaceInput(1, msub.right().node()); |
| 240 return Changed(node); | 240 return Changed(node); |
| 241 } | 241 } |
| 242 // TODO(turbofan): fold HeapConstant, ExternalReference, pointer compares | 242 // TODO(turbofan): fold HeapConstant, ExternalReference, pointer compares |
| 243 if (m.LeftEqualsRight()) return ReplaceBool(true); // x == x => true | 243 if (m.LeftEqualsRight()) return ReplaceBool(true); // x == x => true |
| 244 break; | 244 break; |
| 245 } | 245 } |
| 246 case IrOpcode::kWord64Equal: { |
| 247 Int64BinopMatcher m(node); |
| 248 if (m.IsFoldable()) { // K == K => K |
| 249 return ReplaceBool(m.left().Value() == m.right().Value()); |
| 250 } |
| 251 if (m.left().IsInt64Sub() && m.right().Is(0)) { // x - y == 0 => x == y |
| 252 Int64BinopMatcher msub(m.left().node()); |
| 253 node->ReplaceInput(0, msub.left().node()); |
| 254 node->ReplaceInput(1, msub.right().node()); |
| 255 return Changed(node); |
| 256 } |
| 257 // TODO(turbofan): fold HeapConstant, ExternalReference, pointer compares |
| 258 if (m.LeftEqualsRight()) return ReplaceBool(true); // x == x => true |
| 259 break; |
| 260 } |
| 246 case IrOpcode::kInt32Add: { | 261 case IrOpcode::kInt32Add: { |
| 247 Int32BinopMatcher m(node); | 262 Int32BinopMatcher m(node); |
| 248 if (m.right().Is(0)) return Replace(m.left().node()); // x + 0 => x | 263 if (m.right().Is(0)) return Replace(m.left().node()); // x + 0 => x |
| 249 if (m.IsFoldable()) { // K + K => K | 264 if (m.IsFoldable()) { // K + K => K |
| 250 return ReplaceInt32(static_cast<uint32_t>(m.left().Value()) + | 265 return ReplaceInt32(static_cast<uint32_t>(m.left().Value()) + |
| 251 static_cast<uint32_t>(m.right().Value())); | 266 static_cast<uint32_t>(m.right().Value())); |
| 252 } | 267 } |
| 253 break; | 268 break; |
| 254 } | 269 } |
| 255 case IrOpcode::kInt32Sub: { | 270 case IrOpcode::kInt32Sub: { |
| (...skipping 413 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 669 MachineOperatorBuilder* MachineOperatorReducer::machine() const { | 684 MachineOperatorBuilder* MachineOperatorReducer::machine() const { |
| 670 return jsgraph()->machine(); | 685 return jsgraph()->machine(); |
| 671 } | 686 } |
| 672 | 687 |
| 673 | 688 |
| 674 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } | 689 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } |
| 675 | 690 |
| 676 } // namespace compiler | 691 } // namespace compiler |
| 677 } // namespace internal | 692 } // namespace internal |
| 678 } // namespace v8 | 693 } // namespace v8 |
| OLD | NEW |