From 0c7f91cf843247a34ae9147af0708d238d43f9f9 Mon Sep 17 00:00:00 2001 From: Owen Anderson Date: Wed, 3 Sep 2008 23:06:07 +0000 Subject: [PATCH] Fix a bug that prevented PRE from applying in some cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@55744 91177308-0d34-0410-b5e6-96231b3b80d8 --- lib/Transforms/Scalar/GVN.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/lib/Transforms/Scalar/GVN.cpp b/lib/Transforms/Scalar/GVN.cpp index 42fbc78671e..b258fcc08c0 100644 --- a/lib/Transforms/Scalar/GVN.cpp +++ b/lib/Transforms/Scalar/GVN.cpp @@ -1131,9 +1131,11 @@ bool GVN::runOnFunction(Function& F) { } if (EnablePRE) { - bool PREChanged = false; - while ((PREChanged = performPRE(F))) + bool PREChanged = true; + while (PREChanged) { + PREChanged = performPRE(F); changed |= PREChanged; + } } return changed; @@ -1256,7 +1258,7 @@ bool GVN::performPRE(Function& F) { unsigned succNum = 0; for (unsigned i = 0, e = PREPred->getTerminator()->getNumSuccessors(); i != e; ++i) - if (PREPred->getTerminator()->getSuccessor(i) == PREPred) { + if (PREPred->getTerminator()->getSuccessor(i) == CurrentBlock) { succNum = i; break; } -- 2.34.1