1
0
mirror of https://github.com/RPCS3/llvm-mirror.git synced 2024-11-25 04:02:41 +01:00

Fix PR3913, patch by Jakub Staszak!

llvm-svn: 80327
This commit is contained in:
Chris Lattner 2009-08-28 00:43:14 +00:00
parent 2d5d3700e9
commit f37893e7a1
2 changed files with 25 additions and 1 deletions

View File

@ -435,7 +435,7 @@ bool LoopIndexSplit::processOneIterationLoop() {
CmpInst::Predicate C2P = ExitCondition->getPredicate();
BranchInst *LatchBR = cast<BranchInst>(Latch->getTerminator());
if (LatchBR->getOperand(0) != Header)
if (LatchBR->getOperand(1) != Header)
C2P = CmpInst::getInversePredicate(C2P);
Instruction *C2 = new ICmpInst(BR, C2P, SplitValue, ExitValue, "lisplit");
Instruction *NSplitCond = BinaryOperator::CreateAnd(C1, C2, "lisplit", BR);

View File

@ -0,0 +1,24 @@
; RUN: llvm-as < %s | opt -loop-index-split | llvm-dis | not grep "icmp ne"
define i32 @main() {
entry:
br label %header
header:
%r = phi i32 [ 0, %entry ], [ %r3, %skip ]
%i = phi i32 [ 0, %entry ], [ %i1, %skip ]
%cond = icmp eq i32 %i, 99
br i1 %cond, label %body, label %skip
body:
br label %skip
skip:
%r3 = phi i32 [ %r, %header ], [ 3, %body ]
%i1 = add i32 %i, 1
%exitcond = icmp eq i32 %i1, 10
br i1 %exitcond, label %exit, label %header
exit:
ret i32 %r3
}