From 4a69da9cb01bae8f90c444722afa51f15d067ea4 Mon Sep 17 00:00:00 2001 From: Devang Patel Date: Sat, 25 Aug 2007 00:56:38 +0000 Subject: While calculating upper loop bound for first loop and lower loop bound for second loop, take care of edge cases. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41387 91177308-0d34-0410-b5e6-96231b3b80d8 --- .../LoopIndexSplit/SplitValue-2007-08-24.ll | 52 ++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100644 test/Transforms/LoopIndexSplit/SplitValue-2007-08-24.ll (limited to 'test/Transforms/LoopIndexSplit/SplitValue-2007-08-24.ll') diff --git a/test/Transforms/LoopIndexSplit/SplitValue-2007-08-24.ll b/test/Transforms/LoopIndexSplit/SplitValue-2007-08-24.ll new file mode 100644 index 0000000..27327a0 --- /dev/null +++ b/test/Transforms/LoopIndexSplit/SplitValue-2007-08-24.ll @@ -0,0 +1,52 @@ +; Split loop. Save last value. Split value is off by one in this example. +; RUN: llvm-as < %s | opt -loop-index-split -disable-output -stats |& \ +; RUN: grep "loop-index-split" | count 1 + +@k = external global i32 ; [#uses=2] + +define void @foobar(i32 %a, i32 %b) { +entry: + br label %bb + +bb: ; preds = %cond_next16, %entry + %i.01.0 = phi i32 [ 0, %entry ], [ %tmp18, %cond_next16 ] ; [#uses=5] + %tsum.18.0 = phi i32 [ 42, %entry ], [ %tsum.013.1, %cond_next16 ] ; [#uses=3] + %tmp1 = icmp sgt i32 %i.01.0, 50 ; [#uses=1] + br i1 %tmp1, label %cond_true, label %cond_false + +cond_true: ; preds = %bb + %tmp4 = tail call i32 @foo( i32 %i.01.0 ) ; [#uses=1] + %tmp6 = add i32 %tmp4, %tsum.18.0 ; [#uses=2] + %tmp914 = load i32* @k, align 4 ; [#uses=1] + %tmp1015 = icmp eq i32 %tmp914, 0 ; [#uses=1] + br i1 %tmp1015, label %cond_next16, label %cond_true13 + +cond_false: ; preds = %bb + %tmp8 = tail call i32 @bar( i32 %i.01.0 ) ; [#uses=0] + %tmp9 = load i32* @k, align 4 ; [#uses=1] + %tmp10 = icmp eq i32 %tmp9, 0 ; [#uses=1] + br i1 %tmp10, label %cond_next16, label %cond_true13 + +cond_true13: ; preds = %cond_false, %cond_true + %tsum.013.0 = phi i32 [ %tmp6, %cond_true ], [ %tsum.18.0, %cond_false ] ; [#uses=1] + %tmp15 = tail call i32 @bar( i32 %i.01.0 ) ; [#uses=0] + br label %cond_next16 + +cond_next16: ; preds = %cond_false, %cond_true, %cond_true13 + %tsum.013.1 = phi i32 [ %tsum.013.0, %cond_true13 ], [ %tmp6, %cond_true ], [ %tsum.18.0, %cond_false ] ; [#uses=2] + %tmp18 = add i32 %i.01.0, 1 ; [#uses=3] + %tmp21 = icmp slt i32 %tmp18, 100 ; [#uses=1] + br i1 %tmp21, label %bb, label %bb24 + +bb24: ; preds = %cond_next16 + %tmp18.lcssa = phi i32 [ %tmp18, %cond_next16 ] ; [#uses=1] + %tsum.013.1.lcssa = phi i32 [ %tsum.013.1, %cond_next16 ] ; [#uses=1] + %tmp27 = tail call i32 @t( i32 %tmp18.lcssa, i32 %tsum.013.1.lcssa ) ; [#uses=0] + ret void +} + +declare i32 @foo(i32) + +declare i32 @bar(i32) + +declare i32 @t(i32, i32) -- cgit v1.1