diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 4e4d8c127e3..c6645463655 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -1136,8 +1136,11 @@ bool GVN::runOnFunction(Function& F) { changed |= shouldContinue; } - if (EnablePRE) - changed |= performPRE(F); + if (EnablePRE) { + bool PREChanged = false; + while (PREChanged = performPRE(F)) + changed |= PREChanged; + } return changed; } @@ -1336,7 +1339,7 @@ bool GVN::performPRE(Function& F) { I = toSplit.begin(), E = toSplit.end(); I != E; ++I) SplitCriticalEdge(I->first, I->second, this); - return changed; + return changed || toSplit.size(); } // iterateOnFunction - Executes one iteration of GVN