diff options
| author | Chris Lattner <sabre@nondot.org> | 2009-08-28 00:43:14 +0000 |
|---|---|---|
| committer | Chris Lattner <sabre@nondot.org> | 2009-08-28 00:43:14 +0000 |
| commit | bda82c20f3f01cbb8ca559e9891b48511530b5f6 (patch) | |
| tree | af79c566687295bfaece2e003a57a0bad08bcaaa /llvm | |
| parent | cd50d379ee1f497b86140545c31dc07a7e7ac924 (diff) | |
| download | bcm5719-llvm-bda82c20f3f01cbb8ca559e9891b48511530b5f6.tar.gz bcm5719-llvm-bda82c20f3f01cbb8ca559e9891b48511530b5f6.zip | |
Fix PR3913, patch by Jakub Staszak!
llvm-svn: 80327
Diffstat (limited to 'llvm')
| -rw-r--r-- | llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp | 2 | ||||
| -rw-r--r-- | llvm/test/Transforms/LoopIndexSplit/PR3913.ll | 24 |
2 files changed, 25 insertions, 1 deletions
diff --git a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp index 792b7537e52..259427e99bc 100644 --- a/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp +++ b/llvm/lib/Transforms/Scalar/LoopIndexSplit.cpp @@ -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); diff --git a/llvm/test/Transforms/LoopIndexSplit/PR3913.ll b/llvm/test/Transforms/LoopIndexSplit/PR3913.ll new file mode 100644 index 00000000000..c4fc0d1c5e7 --- /dev/null +++ b/llvm/test/Transforms/LoopIndexSplit/PR3913.ll @@ -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 +} |

