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

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

Issue 972653002: [turbofan] Strength reduction of Word32And with Int32Mul. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 5 years, 9 months 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
« 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/diamond.h" 10 #include "src/compiler/diamond.h"
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 if (mleftright.right().Is(base::bits::CountTrailingZeros32(mask))) { 899 if (mleftright.right().Is(base::bits::CountTrailingZeros32(mask))) {
900 // (x + y << L) & (-1 << L) => (x & (-1 << L)) + y << L 900 // (x + y << L) & (-1 << L) => (x & (-1 << L)) + y << L
901 node->set_op(machine()->Int32Add()); 901 node->set_op(machine()->Int32Add());
902 node->ReplaceInput(0, 902 node->ReplaceInput(0,
903 Word32And(mleft.left().node(), m.right().node())); 903 Word32And(mleft.left().node(), m.right().node()));
904 node->ReplaceInput(1, mleftright.node()); 904 node->ReplaceInput(1, mleftright.node());
905 Reduction const reduction = ReduceInt32Add(node); 905 Reduction const reduction = ReduceInt32Add(node);
906 return reduction.Changed() ? reduction : Changed(node); 906 return reduction.Changed() ? reduction : Changed(node);
907 } 907 }
908 } 908 }
909 } else if (m.left().IsInt32Mul()) {
910 Int32BinopMatcher mleft(m.left().node());
911 if (mleft.right().IsMultipleOf(-mask)) {
912 // (x * (K << L)) & (-1 << L) => x * (K << L)
913 return Replace(mleft.node());
914 }
909 } 915 }
910 } 916 }
911 return NoChange(); 917 return NoChange();
912 } 918 }
913 919
914 920
915 Reduction MachineOperatorReducer::ReduceWord32Or(Node* node) { 921 Reduction MachineOperatorReducer::ReduceWord32Or(Node* node) {
916 DCHECK_EQ(IrOpcode::kWord32Or, node->opcode()); 922 DCHECK_EQ(IrOpcode::kWord32Or, node->opcode());
917 Int32BinopMatcher m(node); 923 Int32BinopMatcher m(node);
918 if (m.right().Is(0)) return Replace(m.left().node()); // x | 0 => x 924 if (m.right().Is(0)) return Replace(m.left().node()); // x | 0 => x
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
977 MachineOperatorBuilder* MachineOperatorReducer::machine() const { 983 MachineOperatorBuilder* MachineOperatorReducer::machine() const {
978 return jsgraph()->machine(); 984 return jsgraph()->machine();
979 } 985 }
980 986
981 987
982 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } 988 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
983 989
984 } // namespace compiler 990 } // namespace compiler
985 } // namespace internal 991 } // namespace internal
986 } // namespace v8 992 } // 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