Reject a case we don't handle yet
authorChris Lattner <sabre@nondot.org>
Mon, 19 Sep 2005 23:57:04 +0000 (23:57 +0000)
committerChris Lattner <sabre@nondot.org>
Mon, 19 Sep 2005 23:57:04 +0000 (23:57 +0000)
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@23393 91177308-0d34-0410-b5e6-96231b3b80d8

lib/Transforms/Utils/SimplifyCFG.cpp

index 08403aeca83ce8a4a3f1b4299417fb33d587b49e..c0cb2f42b1ea395ffc9ef06c414089ba11bc02e4 100644 (file)
@@ -897,7 +897,9 @@ HoistTerminator:
 static bool FoldCondBranchOnPHI(BranchInst *BI) {
   BasicBlock *BB = BI->getParent();
   PHINode *PN = dyn_cast<PHINode>(BI->getCondition());
-  if (!PN || PN->getParent() != BB) return false;
+  // NOTE: we currently cannot transform this case if the PHI node is used
+  // outside of the block.
+  if (!PN || PN->getParent() != BB || !PN->hasOneUse()) return false;
   
   // Degenerate case of a single entry PHI.
   if (PN->getNumIncomingValues() == 1) {