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

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

Issue 469213002: [turbofan] Introduce WordRor machine operator. (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Fix BUILD.gn Created 6 years, 4 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
« no previous file with comments | « src/compiler/machine-operator.h ('k') | src/compiler/opcodes.h » ('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 4a4057646dde8bc0f60c8866207f52512ea06387..8466cbbf47537f22b8b750fb5ea8dd38b41962d8 100644
--- a/src/compiler/machine-operator-reducer.cc
+++ b/src/compiler/machine-operator-reducer.cc
@@ -4,6 +4,7 @@
#include "src/compiler/machine-operator-reducer.h"
+#include "src/base/bits.h"
#include "src/compiler/common-node-cache.h"
#include "src/compiler/generic-node-inl.h"
#include "src/compiler/graph.h"
@@ -67,6 +68,56 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
return ReplaceInt32(m.left().Value() | m.right().Value());
}
if (m.LeftEqualsRight()) return Replace(m.left().node()); // x | x => x
+ if (m.left().IsWord32Shl() && m.right().IsWord32Shr()) {
+ Int32BinopMatcher mleft(m.left().node());
+ Int32BinopMatcher mright(m.right().node());
+ if (mleft.left().node() == mright.left().node()) {
+ // (x << y) | (x >> (32 - y)) => x ror y
+ if (mright.right().IsInt32Sub()) {
+ Int32BinopMatcher mrightright(mright.right().node());
+ if (mrightright.left().Is(32) &&
+ mrightright.right().node() == mleft.right().node()) {
+ graph_->ChangeOperator(node, machine_.Word32Ror());
+ node->ReplaceInput(0, mleft.left().node());
+ node->ReplaceInput(1, mleft.right().node());
+ return Changed(node);
+ }
+ }
+ // (x << K) | (x >> (32 - K)) => x ror K
+ if (mleft.right().IsInRange(0, 31) &&
+ mright.right().Is(32 - mleft.right().Value())) {
+ graph_->ChangeOperator(node, machine_.Word32Ror());
+ node->ReplaceInput(0, mleft.left().node());
+ node->ReplaceInput(1, mleft.right().node());
+ return Changed(node);
+ }
+ }
+ }
+ if (m.left().IsWord32Shr() && m.right().IsWord32Shl()) {
+ // (x >> (32 - y)) | (x << y) => x ror y
+ Int32BinopMatcher mleft(m.left().node());
+ Int32BinopMatcher mright(m.right().node());
+ if (mleft.left().node() == mright.left().node()) {
+ if (mleft.right().IsInt32Sub()) {
+ Int32BinopMatcher mleftright(mleft.right().node());
+ if (mleftright.left().Is(32) &&
+ mleftright.right().node() == mright.right().node()) {
+ graph_->ChangeOperator(node, machine_.Word32Ror());
+ node->ReplaceInput(0, mright.left().node());
+ node->ReplaceInput(1, mright.right().node());
+ return Changed(node);
+ }
+ }
+ // (x >> (32 - K)) | (x << K) => x ror K
+ if (mright.right().IsInRange(0, 31) &&
+ mleft.right().Is(32 - mright.right().Value())) {
+ graph_->ChangeOperator(node, machine_.Word32Ror());
+ node->ReplaceInput(0, mright.left().node());
+ node->ReplaceInput(1, mright.right().node());
+ return Changed(node);
+ }
+ }
+ }
break;
}
case IrOpcode::kWord32Xor: {
@@ -102,6 +153,15 @@ Reduction MachineOperatorReducer::Reduce(Node* node) {
}
break;
}
+ case IrOpcode::kWord32Ror: {
+ Int32BinopMatcher m(node);
+ if (m.right().Is(0)) return Replace(m.left().node()); // x ror 0 => x
+ if (m.IsFoldable()) { // K ror K => K
+ return ReplaceInt32(
+ base::bits::RotateRight32(m.left().Value(), m.right().Value()));
+ }
+ break;
+ }
case IrOpcode::kWord32Equal: {
Int32BinopMatcher m(node);
if (m.IsFoldable()) { // K == K => K
« no previous file with comments | « src/compiler/machine-operator.h ('k') | src/compiler/opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698