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

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

Issue 685713002: [turbofan] Reduce (x & K) & K to x & K. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: 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/unittests/compiler/machine-operator-reducer-unittest.cc » ('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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after
102 case IrOpcode::kProjection: 102 case IrOpcode::kProjection:
103 return ReduceProjection(OpParameter<size_t>(node), node->InputAt(0)); 103 return ReduceProjection(OpParameter<size_t>(node), node->InputAt(0));
104 case IrOpcode::kWord32And: { 104 case IrOpcode::kWord32And: {
105 Int32BinopMatcher m(node); 105 Int32BinopMatcher m(node);
106 if (m.right().Is(0)) return Replace(m.right().node()); // x & 0 => 0 106 if (m.right().Is(0)) return Replace(m.right().node()); // x & 0 => 0
107 if (m.right().Is(-1)) return Replace(m.left().node()); // x & -1 => x 107 if (m.right().Is(-1)) return Replace(m.left().node()); // x & -1 => x
108 if (m.IsFoldable()) { // K & K => K 108 if (m.IsFoldable()) { // K & K => K
109 return ReplaceInt32(m.left().Value() & m.right().Value()); 109 return ReplaceInt32(m.left().Value() & m.right().Value());
110 } 110 }
111 if (m.LeftEqualsRight()) return Replace(m.left().node()); // x & x => x 111 if (m.LeftEqualsRight()) return Replace(m.left().node()); // x & x => x
112 if (m.left().IsWord32And() && m.right().HasValue()) {
113 Int32BinopMatcher mleft(m.left().node());
114 if (mleft.right().HasValue()) { // (x & K) & K => x & K
115 node->ReplaceInput(0, mleft.left().node());
116 node->ReplaceInput(
117 1, Int32Constant(m.right().Value() & mleft.right().Value()));
118 return Changed(node);
119 }
120 }
112 break; 121 break;
113 } 122 }
114 case IrOpcode::kWord32Or: { 123 case IrOpcode::kWord32Or: {
115 Int32BinopMatcher m(node); 124 Int32BinopMatcher m(node);
116 if (m.right().Is(0)) return Replace(m.left().node()); // x | 0 => x 125 if (m.right().Is(0)) return Replace(m.left().node()); // x | 0 => x
117 if (m.right().Is(-1)) return Replace(m.right().node()); // x | -1 => -1 126 if (m.right().Is(-1)) return Replace(m.right().node()); // x | -1 => -1
118 if (m.IsFoldable()) { // K | K => K 127 if (m.IsFoldable()) { // K | K => K
119 return ReplaceInt32(m.left().Value() | m.right().Value()); 128 return ReplaceInt32(m.left().Value() | m.right().Value());
120 } 129 }
121 if (m.LeftEqualsRight()) return Replace(m.left().node()); // x | x => x 130 if (m.LeftEqualsRight()) return Replace(m.left().node()); // x | x => x
(...skipping 584 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 MachineOperatorBuilder* MachineOperatorReducer::machine() const { 715 MachineOperatorBuilder* MachineOperatorReducer::machine() const {
707 return jsgraph()->machine(); 716 return jsgraph()->machine();
708 } 717 }
709 718
710 719
711 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } 720 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
712 721
713 } // namespace compiler 722 } // namespace compiler
714 } // namespace internal 723 } // namespace internal
715 } // namespace v8 724 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | test/unittests/compiler/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698