Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(50)

Side by Side Diff: src/compiler/machine-operator-reducer.cc

Issue 689883003: Fix bug in optimization of Uint32LessThan. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Add TODO(turbofan) Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | test/mjsunit/asm/uint32-less-than-shift.js » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
363 Uint32BinopMatcher m(node); 363 Uint32BinopMatcher m(node);
364 if (m.left().Is(kMaxUInt32)) return ReplaceBool(false); // M < x => false 364 if (m.left().Is(kMaxUInt32)) return ReplaceBool(false); // M < x => false
365 if (m.right().Is(0)) return ReplaceBool(false); // x < 0 => false 365 if (m.right().Is(0)) return ReplaceBool(false); // x < 0 => false
366 if (m.IsFoldable()) { // K < K => K 366 if (m.IsFoldable()) { // K < K => K
367 return ReplaceBool(m.left().Value() < m.right().Value()); 367 return ReplaceBool(m.left().Value() < m.right().Value());
368 } 368 }
369 if (m.LeftEqualsRight()) return ReplaceBool(false); // x < x => false 369 if (m.LeftEqualsRight()) return ReplaceBool(false); // x < x => false
370 if (m.left().IsWord32Sar() && m.right().HasValue()) { 370 if (m.left().IsWord32Sar() && m.right().HasValue()) {
371 Int32BinopMatcher mleft(m.left().node()); 371 Int32BinopMatcher mleft(m.left().node());
372 if (mleft.right().HasValue()) { 372 if (mleft.right().HasValue()) {
373 // (x >> K) < C => x < (C << K) | (2^K - 1) 373 // (x >> K) < C => x < (C << K)
374 // when C < (M >> K) 374 // when C < (M >> K)
375 const uint32_t c = m.right().Value(); 375 const uint32_t c = m.right().Value();
376 const uint32_t k = mleft.right().Value() & 0x1f; 376 const uint32_t k = mleft.right().Value() & 0x1f;
377 if (c < static_cast<uint32_t>(kMaxInt >> k)) { 377 if (c < static_cast<uint32_t>(kMaxInt >> k)) {
378 node->ReplaceInput(0, mleft.left().node()); 378 node->ReplaceInput(0, mleft.left().node());
379 node->ReplaceInput(1, Uint32Constant((c << k) | ((1 << k) - 1))); 379 node->ReplaceInput(1, Uint32Constant(c << k));
380 return Changed(node); 380 return Changed(node);
381 } 381 }
382 // TODO(turbofan): else the comparison is always true.
382 } 383 }
383 } 384 }
384 break; 385 break;
385 } 386 }
386 case IrOpcode::kUint32LessThanOrEqual: { 387 case IrOpcode::kUint32LessThanOrEqual: {
387 Uint32BinopMatcher m(node); 388 Uint32BinopMatcher m(node);
388 if (m.left().Is(0)) return ReplaceBool(true); // 0 <= x => true 389 if (m.left().Is(0)) return ReplaceBool(true); // 0 <= x => true
389 if (m.right().Is(kMaxUInt32)) return ReplaceBool(true); // x <= M => true 390 if (m.right().Is(kMaxUInt32)) return ReplaceBool(true); // x <= M => true
390 if (m.IsFoldable()) { // K <= K => K 391 if (m.IsFoldable()) { // K <= K => K
391 return ReplaceBool(m.left().Value() <= m.right().Value()); 392 return ReplaceBool(m.left().Value() <= m.right().Value());
(...skipping 328 matching lines...) Expand 10 before | Expand all | Expand 10 after
720 MachineOperatorBuilder* MachineOperatorReducer::machine() const { 721 MachineOperatorBuilder* MachineOperatorReducer::machine() const {
721 return jsgraph()->machine(); 722 return jsgraph()->machine();
722 } 723 }
723 724
724 725
725 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } 726 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
726 727
727 } // namespace compiler 728 } // namespace compiler
728 } // namespace internal 729 } // namespace internal
729 } // namespace v8 730 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/mjsunit/asm/uint32-less-than-shift.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698