Commit 2f21ddfb authored by bmeurer@chromium.org's avatar bmeurer@chromium.org

[turbofan] GraphReducer is more "fixpointish" now.

R=jarin@chromium.org

Review URL: https://codereview.chromium.org/605933002

git-svn-id: https://v8.googlecode.com/svn/branches/bleeding_edge@24236 ce2b1a6d-e550-0410-aec6-3dcde31c8c00
parent 31c39284
...@@ -97,15 +97,16 @@ TEST_F(GraphReducerTest, ReduceOnceForEveryReducer) { ...@@ -97,15 +97,16 @@ TEST_F(GraphReducerTest, ReduceOnceForEveryReducer) {
TEST_F(GraphReducerTest, ReduceAgainAfterChanged) { TEST_F(GraphReducerTest, ReduceAgainAfterChanged) {
Sequence s1, s2; Sequence s1, s2, s3;
StrictMock<MockReducer> r1, r2, r3; StrictMock<MockReducer> r1, r2, r3;
Node* node0 = graph()->NewNode(&OP0); Node* node0 = graph()->NewNode(&OP0);
EXPECT_CALL(r1, Reduce(node0)); EXPECT_CALL(r1, Reduce(node0));
EXPECT_CALL(r2, Reduce(node0)); EXPECT_CALL(r2, Reduce(node0));
EXPECT_CALL(r3, Reduce(node0)).InSequence(s1, s2).WillOnce( EXPECT_CALL(r3, Reduce(node0)).InSequence(s1, s2, s3).WillOnce(
Return(Reducer::Changed(node0))); Return(Reducer::Changed(node0)));
EXPECT_CALL(r1, Reduce(node0)).InSequence(s1); EXPECT_CALL(r1, Reduce(node0)).InSequence(s1);
EXPECT_CALL(r2, Reduce(node0)).InSequence(s2); EXPECT_CALL(r2, Reduce(node0)).InSequence(s2);
EXPECT_CALL(r3, Reduce(node0)).InSequence(s3);
ReduceNode(node0, &r1, &r2, &r3); ReduceNode(node0, &r1, &r2, &r3);
} }
......
...@@ -22,7 +22,6 @@ static bool NodeIdIsLessThan(const Node* node, NodeId id) { ...@@ -22,7 +22,6 @@ static bool NodeIdIsLessThan(const Node* node, NodeId id) {
void GraphReducer::ReduceNode(Node* node) { void GraphReducer::ReduceNode(Node* node) {
ZoneVector<Reducer*>::iterator skip = reducers_.end();
static const unsigned kMaxAttempts = 16; static const unsigned kMaxAttempts = 16;
bool reduce = true; bool reduce = true;
for (unsigned attempts = 0; attempts <= kMaxAttempts; ++attempts) { for (unsigned attempts = 0; attempts <= kMaxAttempts; ++attempts) {
...@@ -31,17 +30,15 @@ void GraphReducer::ReduceNode(Node* node) { ...@@ -31,17 +30,15 @@ void GraphReducer::ReduceNode(Node* node) {
int before = graph_->NodeCount(); int before = graph_->NodeCount();
for (ZoneVector<Reducer*>::iterator i = reducers_.begin(); for (ZoneVector<Reducer*>::iterator i = reducers_.begin();
i != reducers_.end(); ++i) { i != reducers_.end(); ++i) {
if (i == skip) continue; // Skip this reducer.
Reduction reduction = (*i)->Reduce(node); Reduction reduction = (*i)->Reduce(node);
Node* replacement = reduction.replacement(); Node* replacement = reduction.replacement();
if (replacement == NULL) { if (replacement == NULL) {
// No change from this reducer. // No change from this reducer.
} else if (replacement == node) { } else if (replacement == node) {
// {replacement == node} represents an in-place reduction. // {replacement == node} represents an in-place reduction.
// Rerun all the reducers except the current one for this node, // Rerun all the reducers for this node, as now there may be more
// as now there may be more opportunities for reduction. // opportunities for reduction.
reduce = true; reduce = true;
skip = i;
break; break;
} else { } else {
if (node == graph_->start()) graph_->SetStart(replacement); if (node == graph_->start()) graph_->SetStart(replacement);
...@@ -63,7 +60,6 @@ void GraphReducer::ReduceNode(Node* node) { ...@@ -63,7 +60,6 @@ void GraphReducer::ReduceNode(Node* node) {
node->Kill(); node->Kill();
} }
// Rerun all the reductions on the {replacement}. // Rerun all the reductions on the {replacement}.
skip = reducers_.end();
node = replacement; node = replacement;
reduce = true; reduce = true;
break; break;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment