From d6ba41e02dc6b4fb2562745efd25324cf8ab6db7 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Mon, 9 Apr 2007 16:41:46 +0000 Subject: [PATCH] Fix future bug. Of course, Chris spotted this. Handle Argument or Undef as an incoming PHI value. llvm-svn: 35821 --- llvm/lib/Transforms/Scalar/LoopRotation.cpp | 23 +++++++++++---------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/llvm/lib/Transforms/Scalar/LoopRotation.cpp b/llvm/lib/Transforms/Scalar/LoopRotation.cpp index 21430d704fc6..4fab1bf7c75d 100644 --- a/llvm/lib/Transforms/Scalar/LoopRotation.cpp +++ b/llvm/lib/Transforms/Scalar/LoopRotation.cpp @@ -369,7 +369,6 @@ bool LoopRotate::rotateLoop(Loop *Lp, LPPassManager &LPM) { return true; } - /// Make sure all Exit block PHINodes have required incoming values. /// If incoming value is constant or defined outside the loop then /// PHINode may not have an entry for new pre-header. @@ -382,20 +381,22 @@ void LoopRotate::updateExitBlock() { if (!PN) break; - if (PN->getBasicBlockIndex(NewPreHeader) == -1) { - Value *V = PN->getIncomingValueForBlock(OrigHeader); - if (isa(V)) - PN->addIncoming(V, NewPreHeader); - else { - RenameData *ILoopHeaderInfo = findReplacementData(cast(V)); - assert (ILoopHeaderInfo && ILoopHeaderInfo->PreHeader && "Missing New Preheader Instruction"); - PN->addIncoming(ILoopHeaderInfo->PreHeader, NewPreHeader); - } + // There is already one incoming value from new pre-header block. + if (PN->getBasicBlockIndex(NewPreHeader) != -1) + return; + + RenameData *ILoopHeaderInfo; + Value *V = PN->getIncomingValueForBlock(OrigHeader); + if (isa(V) && + (ILoopHeaderInfo = findReplacementData(cast(V)))) { + assert (ILoopHeaderInfo->PreHeader && "Missing New Preheader Instruction"); + PN->addIncoming(ILoopHeaderInfo->PreHeader, NewPreHeader); + } else { + PN->addIncoming(V, NewPreHeader); } } } - /// Initialize local data void LoopRotate::initialize() { L = NULL;