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

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

Issue 758603003: [turbofan] Combine additional Word32And with Int32Add and negative power of two. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Address comment. 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 | 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 761 matching lines...) Expand 10 before | Expand all | Expand 10 after
772 node->ReplaceInput( 772 node->ReplaceInput(
773 1, Int32Constant(m.right().Value() & mleft.right().Value())); 773 1, Int32Constant(m.right().Value() & mleft.right().Value()));
774 Reduction reduction = ReduceWord32And(node); 774 Reduction reduction = ReduceWord32And(node);
775 return reduction.Changed() ? reduction : Changed(node); 775 return reduction.Changed() ? reduction : Changed(node);
776 } 776 }
777 } 777 }
778 if (m.left().IsInt32Add() && m.right().IsNegativePowerOf2()) { 778 if (m.left().IsInt32Add() && m.right().IsNegativePowerOf2()) {
779 Int32BinopMatcher mleft(m.left().node()); 779 Int32BinopMatcher mleft(m.left().node());
780 if (mleft.right().HasValue() && 780 if (mleft.right().HasValue() &&
781 (mleft.right().Value() & m.right().Value()) == mleft.right().Value()) { 781 (mleft.right().Value() & m.right().Value()) == mleft.right().Value()) {
782 // (x + K) & K => (x & K) + K 782 // (x + (K << L)) & (-1 << L) => (x & (-1 << L)) + (K << L)
783 return Replace(graph()->NewNode( 783 return Replace(graph()->NewNode(
784 machine()->Int32Add(), 784 machine()->Int32Add(),
785 graph()->NewNode(machine()->Word32And(), mleft.left().node(), 785 graph()->NewNode(machine()->Word32And(), mleft.left().node(),
786 m.right().node()), 786 m.right().node()),
787 mleft.right().node())); 787 mleft.right().node()));
788 } 788 }
789 if (mleft.left().IsWord32Shl()) {
790 Int32BinopMatcher mleftleft(mleft.left().node());
791 if (mleftleft.right().Is(
792 base::bits::CountTrailingZeros32(m.right().Value()))) {
793 // (y << L + x) & (-1 << L) => (x & (-1 << L)) + y << L
794 return Replace(graph()->NewNode(
795 machine()->Int32Add(),
796 graph()->NewNode(machine()->Word32And(), mleft.right().node(),
797 m.right().node()),
798 mleftleft.node()));
799 }
800 }
801 if (mleft.right().IsWord32Shl()) {
802 Int32BinopMatcher mleftright(mleft.right().node());
803 if (mleftright.right().Is(
804 base::bits::CountTrailingZeros32(m.right().Value()))) {
805 // (x + y << L) & (-1 << L) => (x & (-1 << L)) + y << L
806 return Replace(graph()->NewNode(
807 machine()->Int32Add(),
808 graph()->NewNode(machine()->Word32And(), mleft.left().node(),
809 m.right().node()),
810 mleftright.node()));
811 }
812 }
789 } 813 }
790 return NoChange(); 814 return NoChange();
791 } 815 }
792 816
793 817
794 Reduction MachineOperatorReducer::ReduceWord32Or(Node* node) { 818 Reduction MachineOperatorReducer::ReduceWord32Or(Node* node) {
795 DCHECK_EQ(IrOpcode::kWord32Or, node->opcode()); 819 DCHECK_EQ(IrOpcode::kWord32Or, node->opcode());
796 Int32BinopMatcher m(node); 820 Int32BinopMatcher m(node);
797 if (m.right().Is(0)) return Replace(m.left().node()); // x | 0 => x 821 if (m.right().Is(0)) return Replace(m.left().node()); // x | 0 => x
798 if (m.right().Is(-1)) return Replace(m.right().node()); // x | -1 => -1 822 if (m.right().Is(-1)) return Replace(m.right().node()); // x | -1 => -1
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
856 MachineOperatorBuilder* MachineOperatorReducer::machine() const { 880 MachineOperatorBuilder* MachineOperatorReducer::machine() const {
857 return jsgraph()->machine(); 881 return jsgraph()->machine();
858 } 882 }
859 883
860 884
861 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); } 885 Graph* MachineOperatorReducer::graph() const { return jsgraph()->graph(); }
862 886
863 } // namespace compiler 887 } // namespace compiler
864 } // namespace internal 888 } // namespace internal
865 } // namespace v8 889 } // 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