mirror of
https://github.com/c64scene-ar/llvm-6502.git
synced 2024-12-13 04:30:23 +00:00
[Unroll] Handle SwitchInst properly.
Previously successor selection was simply wrong. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@243545 91177308-0d34-0410-b5e6-96231b3b80d8
This commit is contained in:
parent
815580fe7a
commit
607fe5bb28
@ -619,8 +619,8 @@ analyzeLoopUnrollCost(const Loop *L, unsigned TripCount, ScalarEvolution &SE,
|
|||||||
if (isa<UndefValue>(SimpleCond))
|
if (isa<UndefValue>(SimpleCond))
|
||||||
Succ = SI->getSuccessor(0);
|
Succ = SI->getSuccessor(0);
|
||||||
else
|
else
|
||||||
Succ =
|
Succ = SI->findCaseValue(cast<ConstantInt>(SimpleCond))
|
||||||
SI->getSuccessor(cast<ConstantInt>(SimpleCond)->getSExtValue());
|
.getCaseSuccessor();
|
||||||
if (L->contains(Succ))
|
if (L->contains(Succ))
|
||||||
BBWorklist.insert(Succ);
|
BBWorklist.insert(Succ);
|
||||||
continue;
|
continue;
|
||||||
|
@ -57,3 +57,27 @@ for.inc: ; preds = %for.body, %if.then
|
|||||||
for.end: ; preds = %for.inc
|
for.end: ; preds = %for.inc
|
||||||
ret void
|
ret void
|
||||||
}
|
}
|
||||||
|
|
||||||
|
define void @switch() {
|
||||||
|
entry:
|
||||||
|
br label %for.body
|
||||||
|
|
||||||
|
for.body:
|
||||||
|
%iv.0 = phi i64 [ 0, %entry ], [ %iv.1, %for.inc ]
|
||||||
|
%arrayidx1 = getelementptr inbounds [10 x i32], [10 x i32]* @known_constant, i64 0, i64 %iv.0
|
||||||
|
%x1 = load i32, i32* %arrayidx1, align 4
|
||||||
|
switch i32 %x1, label %l1 [
|
||||||
|
]
|
||||||
|
|
||||||
|
l1:
|
||||||
|
%x2 = add i32 %x1, 2
|
||||||
|
br label %for.inc
|
||||||
|
|
||||||
|
for.inc:
|
||||||
|
%iv.1 = add nuw nsw i64 %iv.0, 1
|
||||||
|
%exitcond = icmp eq i64 %iv.1, 10
|
||||||
|
br i1 %exitcond, label %for.end, label %for.body
|
||||||
|
|
||||||
|
for.end:
|
||||||
|
ret void
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user