[llvm-commits] [llvm] r80327 - in /llvm/trunk: lib/Transforms/Scalar/LoopIndexSplit.cpp test/Transforms/LoopIndexSplit/PR3913.ll

Chris Lattner sabre at nondot.org
Thu Aug 27 17:43:15 PDT 2009


Author: lattner
Date: Thu Aug 27 19:43:14 2009
New Revision: 80327

URL: http://llvm.org/viewvc/llvm-project?rev=80327&view=rev
Log:
Fix PR3913, patch by Jakub Staszak!


Added:
    llvm/trunk/test/Transforms/LoopIndexSplit/PR3913.ll
Modified:
    llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp

Modified: llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp?rev=80327&r1=80326&r2=80327&view=diff

==============================================================================
--- llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp (original)
+++ llvm/trunk/lib/Transforms/Scalar/LoopIndexSplit.cpp Thu Aug 27 19:43:14 2009
@@ -435,7 +435,7 @@
 
   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);

Added: llvm/trunk/test/Transforms/LoopIndexSplit/PR3913.ll
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/test/Transforms/LoopIndexSplit/PR3913.ll?rev=80327&view=auto

==============================================================================
--- llvm/trunk/test/Transforms/LoopIndexSplit/PR3913.ll (added)
+++ llvm/trunk/test/Transforms/LoopIndexSplit/PR3913.ll Thu Aug 27 19:43:14 2009
@@ -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
+}





More information about the llvm-commits mailing list