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

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

Issue 811293002: [turbofan] Further reduction of Word32And with Int32Add. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 6 years 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 | src/compiler/node-matchers.h » ('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 777 matching lines...) Expand 10 before | Expand all | Expand 10 after
788 Int32BinopMatcher mleft(m.left().node()); 788 Int32BinopMatcher mleft(m.left().node());
789 if (mleft.right().HasValue() && 789 if (mleft.right().HasValue() &&
790 (mleft.right().Value() & m.right().Value()) == mleft.right().Value()) { 790 (mleft.right().Value() & m.right().Value()) == mleft.right().Value()) {
791 // (x + (K << L)) & (-1 << L) => (x & (-1 << L)) + (K << L) 791 // (x + (K << L)) & (-1 << L) => (x & (-1 << L)) + (K << L)
792 node->set_op(machine()->Int32Add()); 792 node->set_op(machine()->Int32Add());
793 node->ReplaceInput(0, Word32And(mleft.left().node(), m.right().node())); 793 node->ReplaceInput(0, Word32And(mleft.left().node(), m.right().node()));
794 node->ReplaceInput(1, mleft.right().node()); 794 node->ReplaceInput(1, mleft.right().node());
795 Reduction const reduction = ReduceInt32Add(node); 795 Reduction const reduction = ReduceInt32Add(node);
796 return reduction.Changed() ? reduction : Changed(node); 796 return reduction.Changed() ? reduction : Changed(node);
797 } 797 }
798 if (mleft.left().IsInt32Mul()) {
799 Int32BinopMatcher mleftleft(mleft.left().node());
800 if (mleftleft.right().IsMultipleOf(-m.right().Value())) {
801 // (y * (K << L) + x) & (-1 << L) => (x & (-1 << L)) + y * (K << L)
802 node->set_op(machine()->Int32Add());
803 node->ReplaceInput(0,
804 Word32And(mleft.right().node(), m.right().node()));
805 node->ReplaceInput(1, mleftleft.node());
806 Reduction const reduction = ReduceInt32Add(node);
807 return reduction.Changed() ? reduction : Changed(node);
808 }
809 }
810 if (mleft.right().IsInt32Mul()) {
811 Int32BinopMatcher mleftright(mleft.right().node());
812 if (mleftright.right().IsMultipleOf(-m.right().Value())) {
813 // (x + y * (K << L)) & (-1 << L) => (x & (-1 << L)) + y * (K << L)
814 node->set_op(machine()->Int32Add());
815 node->ReplaceInput(0, Word32And(mleft.left().node(), m.right().node()));
816 node->ReplaceInput(1, mleftright.node());
817 Reduction const reduction = ReduceInt32Add(node);
818 return reduction.Changed() ? reduction : Changed(node);
819 }
820 }
798 if (mleft.left().IsWord32Shl()) { 821 if (mleft.left().IsWord32Shl()) {
799 Int32BinopMatcher mleftleft(mleft.left().node()); 822 Int32BinopMatcher mleftleft(mleft.left().node());
800 if (mleftleft.right().Is( 823 if (mleftleft.right().Is(
801 base::bits::CountTrailingZeros32(m.right().Value()))) { 824 base::bits::CountTrailingZeros32(m.right().Value()))) {
802 // (y << L + x) & (-1 << L) => (x & (-1 << L)) + y << L 825 // (y << L + x) & (-1 << L) => (x & (-1 << L)) + y << L
803 node->set_op(machine()->Int32Add()); 826 node->set_op(machine()->Int32Add());
804 node->ReplaceInput(0, 827 node->ReplaceInput(0,
805 Word32And(mleft.right().node(), m.right().node())); 828 Word32And(mleft.right().node(), m.right().node()));
806 node->ReplaceInput(1, mleftleft.node()); 829 node->ReplaceInput(1, mleftleft.node());
807 Reduction const reduction = ReduceInt32Add(node); 830 Reduction const reduction = ReduceInt32Add(node);
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
890 MachineOperatorBuilder* MachineOperatorReducer::machine() const { 913 MachineOperatorBuilder* MachineOperatorReducer::machine() const {
891 return jsgraph()->machine(); 914 return jsgraph()->machine();
892 } 915 }
893 916
894 917
895 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } 918 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
896 919
897 } // namespace compiler 920 } // namespace compiler
898 } // namespace internal 921 } // namespace internal
899 } // namespace v8 922 } // namespace v8
OLDNEW
« no previous file with comments | « no previous file | src/compiler/node-matchers.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698