mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-09-30 19:55:11 +00:00
fix PR9013, an infinite loop in instcombine.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@123968 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
084fe6243a
commit
cd151d2f95
@ -538,9 +538,11 @@ Instruction *InstCombiner::FoldOpIntoPhi(Instruction &I) {
|
|||||||
if (!PN->hasOneUse()) {
|
if (!PN->hasOneUse()) {
|
||||||
// Walk the use list for the instruction, comparing them to I.
|
// Walk the use list for the instruction, comparing them to I.
|
||||||
for (Value::use_iterator UI = PN->use_begin(), E = PN->use_end();
|
for (Value::use_iterator UI = PN->use_begin(), E = PN->use_end();
|
||||||
UI != E; ++UI)
|
UI != E; ++UI) {
|
||||||
if (!I.isIdenticalTo(cast<Instruction>(*UI)))
|
Instruction *User = cast<Instruction>(*UI);
|
||||||
|
if (User != &I && !I.isIdenticalTo(User))
|
||||||
return 0;
|
return 0;
|
||||||
|
}
|
||||||
// Otherwise, we can replace *all* users with the new PHI we form.
|
// 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 (InvokeInst *II = dyn_cast<InvokeInst>(InVal))
|
||||||
if (II->getParent() == NonConstBB)
|
if (II->getParent() == NonConstBB)
|
||||||
return 0;
|
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
|
// If there is exactly one non-constant value, we can insert a copy of the
|
||||||
|
@ -353,3 +353,20 @@ entry:
|
|||||||
ret %struct.basic_ios* %0
|
ret %struct.basic_ios* %0
|
||||||
}
|
}
|
||||||
|
|
||||||
|
; PR9013
|
||||||
|
define void @test18() nounwind ssp {
|
||||||
|
entry:
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
for.cond: ; preds = %for.inc, %entry
|
||||||
|
%l_197.0 = phi i32 [ 0, %entry ], [ %sub.i, %for.inc ]
|
||||||
|
br label %for.inc
|
||||||
|
|
||||||
|
for.inc: ; preds = %for.cond
|
||||||
|
%conv = and i32 %l_197.0, 255
|
||||||
|
%sub.i = add nsw i32 %conv, -1
|
||||||
|
br label %for.cond
|
||||||
|
|
||||||
|
return: ; No predecessors!
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user