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/codegen.h" | 8 #include "src/codegen.h" |
9 #include "src/compiler/generic-node-inl.h" | 9 #include "src/compiler/generic-node-inl.h" |
10 #include "src/compiler/graph.h" | 10 #include "src/compiler/graph.h" |
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
332 break; | 332 break; |
333 } | 333 } |
334 case IrOpcode::kUint32LessThan: { | 334 case IrOpcode::kUint32LessThan: { |
335 Uint32BinopMatcher m(node); | 335 Uint32BinopMatcher m(node); |
336 if (m.left().Is(kMaxUInt32)) return ReplaceBool(false); // M < x => false | 336 if (m.left().Is(kMaxUInt32)) return ReplaceBool(false); // M < x => false |
337 if (m.right().Is(0)) return ReplaceBool(false); // x < 0 => false | 337 if (m.right().Is(0)) return ReplaceBool(false); // x < 0 => false |
338 if (m.IsFoldable()) { // K < K => K | 338 if (m.IsFoldable()) { // K < K => K |
339 return ReplaceBool(m.left().Value() < m.right().Value()); | 339 return ReplaceBool(m.left().Value() < m.right().Value()); |
340 } | 340 } |
341 if (m.LeftEqualsRight()) return ReplaceBool(false); // x < x => false | 341 if (m.LeftEqualsRight()) return ReplaceBool(false); // x < x => false |
| 342 if (m.left().IsWord32Sar() && m.right().HasValue()) { |
| 343 Int32BinopMatcher mleft(m.left().node()); |
| 344 if (mleft.right().HasValue()) { |
| 345 // (x >> K) < C => x < (C << K) | (2^K - 1) |
| 346 // when C < (M >> K) |
| 347 const uint32_t c = m.right().Value(); |
| 348 const uint32_t k = mleft.right().Value() & 0x1f; |
| 349 if (c < static_cast<uint32_t>(kMaxInt >> k)) { |
| 350 node->ReplaceInput(0, mleft.left().node()); |
| 351 node->ReplaceInput(1, Uint32Constant((c << k) | ((1 << k) - 1))); |
| 352 return Changed(node); |
| 353 } |
| 354 } |
| 355 } |
342 break; | 356 break; |
343 } | 357 } |
344 case IrOpcode::kUint32LessThanOrEqual: { | 358 case IrOpcode::kUint32LessThanOrEqual: { |
345 Uint32BinopMatcher m(node); | 359 Uint32BinopMatcher m(node); |
346 if (m.left().Is(0)) return ReplaceBool(true); // 0 <= x => true | 360 if (m.left().Is(0)) return ReplaceBool(true); // 0 <= x => true |
347 if (m.right().Is(kMaxUInt32)) return ReplaceBool(true); // x <= M => true | 361 if (m.right().Is(kMaxUInt32)) return ReplaceBool(true); // x <= M => true |
348 if (m.IsFoldable()) { // K <= K => K | 362 if (m.IsFoldable()) { // K <= K => K |
349 return ReplaceBool(m.left().Value() <= m.right().Value()); | 363 return ReplaceBool(m.left().Value() <= m.right().Value()); |
350 } | 364 } |
351 if (m.LeftEqualsRight()) return ReplaceBool(true); // x <= x => true | 365 if (m.LeftEqualsRight()) return ReplaceBool(true); // x <= x => true |
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
541 MachineOperatorBuilder* MachineOperatorReducer::machine() const { | 555 MachineOperatorBuilder* MachineOperatorReducer::machine() const { |
542 return jsgraph()->machine(); | 556 return jsgraph()->machine(); |
543 } | 557 } |
544 | 558 |
545 | 559 |
546 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } | 560 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } |
547 | 561 |
548 } // namespace compiler | 562 } // namespace compiler |
549 } // namespace internal | 563 } // namespace internal |
550 } // namespace v8 | 564 } // namespace v8 |
OLD | NEW |