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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | test/unittests/compiler/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/compiler/machine-operator-reducer.cc
diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc
index 00c998d81a04be79a8606a74d9657d238714d4e4..f8555da33bb7dc1864c3d42caaf8be5defe11d01 100644
--- a/src/compiler/machine-operator-reducer.cc
+++ b/src/compiler/machine-operator-reducer.cc
@@ -779,13 +779,37 @@ Reduction MachineOperatorReducer::ReduceWord32And(Node* node) {
Int32BinopMatcher mleft(m.left().node());
if (mleft.right().HasValue() &&
(mleft.right().Value() & m.right().Value()) == mleft.right().Value()) {
- // (x + K) & K => (x & K) + K
+ // (x + (K << L)) & (-1 << L) => (x & (-1 << L)) + (K << L)
return Replace(graph()->NewNode(
machine()->Int32Add(),
graph()->NewNode(machine()->Word32And(), mleft.left().node(),
m.right().node()),
mleft.right().node()));
}
+ if (mleft.left().IsWord32Shl()) {
+ Int32BinopMatcher mleftleft(mleft.left().node());
+ if (mleftleft.right().Is(
+ base::bits::CountTrailingZeros32(m.right().Value()))) {
+ // (y << L + x) & (-1 << L) => (x & (-1 << L)) + y << L
+ return Replace(graph()->NewNode(
+ machine()->Int32Add(),
+ graph()->NewNode(machine()->Word32And(), mleft.right().node(),
+ m.right().node()),
+ mleftleft.node()));
+ }
+ }
+ if (mleft.right().IsWord32Shl()) {
+ Int32BinopMatcher mleftright(mleft.right().node());
+ if (mleftright.right().Is(
+ base::bits::CountTrailingZeros32(m.right().Value()))) {
+ // (x + y << L) & (-1 << L) => (x & (-1 << L)) + y << L
+ return Replace(graph()->NewNode(
+ machine()->Int32Add(),
+ graph()->NewNode(machine()->Word32And(), mleft.left().node(),
+ m.right().node()),
+ mleftright.node()));
+ }
+ }
}
return NoChange();
}
« 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