summaryrefslogtreecommitdiffstats
path: root/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
diff options
context:
space:
mode:
authorChris Lattner <sabre@nondot.org>2011-01-21 05:29:50 +0000
committerChris Lattner <sabre@nondot.org>2011-01-21 05:29:50 +0000
commitb5e15d1907cd03ea3e1f6e6e675c31be947246a0 (patch)
tree3f988de265085fac26568a369a296df94c124907 /llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
parent4edf1c8968ac8e96265faadcbda341aa4e1431ef (diff)
downloadbcm5719-llvm-b5e15d1907cd03ea3e1f6e6e675c31be947246a0.tar.gz
bcm5719-llvm-b5e15d1907cd03ea3e1f6e6e675c31be947246a0.zip
fix PR9013, an infinite loop in instcombine.
llvm-svn: 123968
Diffstat (limited to 'llvm/lib/Transforms/InstCombine/InstructionCombining.cpp')
-rw-r--r--llvm/lib/Transforms/InstCombine/InstructionCombining.cpp12
1 files changed, 10 insertions, 2 deletions
diff --git a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
index 06fbaad3e48..2d5773a31fc 100644
--- a/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
+++ b/llvm/lib/Transforms/InstCombine/InstructionCombining.cpp
@@ -538,9 +538,11 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) {
if (!PN->hasOneUse()) {
// Walk the use list for the instruction, comparing them to I.
for (Value::use_iterator UI = PN->use_begin(), E = PN->use_end();
- UI != E; ++UI)
- if (!I.isIdenticalTo(cast<Instruction>(*UI)))
+ UI != E; ++UI) {
+ Instruction *User = cast<Instruction>(*UI);
+ if (User != &I && !I.isIdenticalTo(User))
return 0;
+ }
// Otherwise, we can replace *all* users with the new PHI we form.
}
@@ -565,6 +567,12 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) {
if (InvokeInst *II = dyn_cast<InvokeInst>(InVal))
if (II->getParent() == NonConstBB)
return 0;
+
+ // If the incoming non-constant value is in I's block, we will remove one
+ // instruction, but insert another equivalent one, leading to infinite
+ // instcombine.
+ if (NonConstBB == I.getParent())
+ return 0;
}
// If there is exactly one non-constant value, we can insert a copy of the
OpenPOWER on IntegriCloud