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

Unified Diff: src/compiler/machine-operator-reducer.cc

Issue 2069973002: [turbofan] Replace shr of masked bits with zero (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: src/compiler/machine-operator-reducer.cc
diff --git a/src/compiler/machine-operator-reducer.cc b/src/compiler/machine-operator-reducer.cc
index dddf14d0b081afec940f90ee9574f8b6dbfe4712..61ff65022162b55e305eaaef886934fc08196040 100644
--- a/src/compiler/machine-operator-reducer.cc
+++ b/src/compiler/machine-operator-reducer.cc
@@ -153,14 +153,8 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
}
case IrOpcode::kWord32Shl:
return ReduceWord32Shl(node);
- case IrOpcode::kWord32Shr: {
- Uint32BinopMatcher m(node);
- if (m.right().Is(0)) return Replace(m.left().node()); // x >>> 0 => x
- if (m.IsFoldable()) { // K >>> K => K
- return ReplaceInt32(m.left().Value() >> m.right().Value());
- }
- return ReduceWord32Shifts(node);
- }
+ case IrOpcode::kWord32Shr:
+ return ReduceWord32Shr(node);
case IrOpcode::kWord32Sar:
return ReduceWord32Sar(node);
case IrOpcode::kWord32Ror: {
@@ -815,6 +809,25 @@ Reduction MachineOperatorReducer::ReduceWord32Shl(Node* node) {
return ReduceWord32Shifts(node);
}
+Reduction MachineOperatorReducer::ReduceWord32Shr(Node* node) {
+ Uint32BinopMatcher m(node);
+ if (m.right().Is(0)) return Replace(m.left().node()); // x >>> 0 => x
+ if (m.IsFoldable()) { // K >>> K => K
+ return ReplaceInt32(m.left().Value() >> m.right().Value());
+ }
+ if (m.left().IsWord32And() && m.right().HasValue()) {
+ Uint32BinopMatcher mleft(m.left().node());
+ if (mleft.right().HasValue()) {
+ uint32_t shift = m.right().Value() & 0x1f;
+ uint32_t mask = mleft.right().Value();
+ if ((mask >> shift) == 0) {
+ // (m >>> s) == 0 implies ((x & m) >>> s) == 0
+ return ReplaceInt32(0);
+ }
+ }
+ }
+ return ReduceWord32Shifts(node);
+}
Reduction MachineOperatorReducer::ReduceWord32Sar(Node* node) {
Int32BinopMatcher m(node);
« no previous file with comments | « src/compiler/machine-operator-reducer.h ('k') | test/unittests/compiler/machine-operator-reducer-unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698