aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2007-02-24 01:03:45 +0000
committerChris Lattner <sabre@nondot.org>2007-02-24 01:03:45 +0000
commitb3036683c1b9e5061ccbe80a4551be66656c17e0 (patch)
tree2fe76fcc63557dc6b3e20348bf88f43a91fe157a
parent6eaede2e6e657006959cba4bd47dfa0ea6a95f50 (diff)
Fix InstCombine/2007-02-23-PhiFoldInfLoop.ll and PR1217
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@34546 91177308-0d34-0410-b5e6-96231b3b80d8
-rw-r--r--lib/Transforms/Scalar/InstructionCombining.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/Transforms/Scalar/InstructionCombining.cpp b/lib/Transforms/Scalar/InstructionCombining.cpp
index a2011f5511..23dcf0ccde 100644
--- a/lib/Transforms/Scalar/InstructionCombining.cpp
+++ b/lib/Transforms/Scalar/InstructionCombining.cpp
@@ -1641,11 +1641,12 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) {
// Check to see if all of the operands of the PHI are constants. If there is
// one non-constant value, remember the BB it is. If there is more than one
- // bail out.
+ // or if *it* is a PHI, bail out.
BasicBlock *NonConstBB = 0;
for (unsigned i = 0; i != NumPHIValues; ++i)
if (!isa<Constant>(PN->getIncomingValue(i))) {
if (NonConstBB) return 0; // More than one non-const value.
+ if (isa<PHINode>(PN->getIncomingValue(i))) return 0; // Itself a phi.
NonConstBB = PN->getIncomingBlock(i);
// If the incoming non-constant value is in I's block, we have an infinite