summaryrefslogtreecommitdiffstats
path: root/test/Transforms/LoopIndexSplit
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2007-08-17 22:02:15 +0000
committerDevang Patel <dpatel@apple.com>2007-08-17 22:02:15 +0000
commit7bfd5dba387088b371f0d904364e976a71afbd4f (patch)
treeb3734899857f120a0cfff34240209187017a959c /test/Transforms/LoopIndexSplit
parent96bf524b531fd404b118fad7bbe410e9aceeaa5d (diff)
downloadexternal_llvm-7bfd5dba387088b371f0d904364e976a71afbd4f.zip
external_llvm-7bfd5dba387088b371f0d904364e976a71afbd4f.tar.gz
external_llvm-7bfd5dba387088b371f0d904364e976a71afbd4f.tar.bz2
Add loop index split tests.
git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@41146 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test/Transforms/LoopIndexSplit')
-rw-r--r--test/Transforms/LoopIndexSplit/Crash-2007-08-17.ll53
-rw-r--r--test/Transforms/LoopIndexSplit/Crash2-2007-08-17.ll59
-rw-r--r--test/Transforms/LoopIndexSplit/OneIterLoop-2007-08-17.ll61
-rw-r--r--test/Transforms/LoopIndexSplit/OneIterLoop2-2007-08-17.ll62
-rw-r--r--test/Transforms/LoopIndexSplit/OneIterLoop3-2007-08-17.ll35
-rw-r--r--test/Transforms/LoopIndexSplit/SaveLastValue-2007-08-17.ll52
-rw-r--r--test/Transforms/LoopIndexSplit/dg.exp3
7 files changed, 325 insertions, 0 deletions
diff --git a/test/Transforms/LoopIndexSplit/Crash-2007-08-17.ll b/test/Transforms/LoopIndexSplit/Crash-2007-08-17.ll
new file mode 100644
index 0000000..71fccce
--- /dev/null
+++ b/test/Transforms/LoopIndexSplit/Crash-2007-08-17.ll
@@ -0,0 +1,53 @@
+; RUN: llvm-as < %s | opt -loop-index-split -disable-output -stats |& \
+; RUN: grep "loop-index-split" | count 1
+
+ %struct._edit_script = type { %struct._edit_script*, i32, i8 }
+
+define void @align_path(i8* %seq1, i8* %seq2, i32 %i1, i32 %j1, i32 %i2, i32 %j2, i32 %dist, %struct._edit_script** %head, %struct._edit_script** %tail, i32 %M, i32 %N) {
+entry:
+ br label %bb354
+
+bb354: ; preds = %bb511, %entry
+ br i1 false, label %bb495, label %bb368
+
+bb368: ; preds = %bb354
+ ret void
+
+bb495: ; preds = %bb495, %bb354
+ br i1 false, label %bb511, label %bb495
+
+bb511: ; preds = %bb495
+ br i1 false, label %xmalloc.exit69, label %bb354
+
+xmalloc.exit69: ; preds = %bb511
+ br i1 false, label %bb556, label %bb542.preheader
+
+bb542.preheader: ; preds = %xmalloc.exit69
+ ret void
+
+bb556: ; preds = %xmalloc.exit69
+ br label %bb583
+
+bb583: ; preds = %cond_next693, %bb556
+ %k.4342.0 = phi i32 [ %tmp707, %cond_next693 ], [ 0, %bb556 ] ; <i32> [#uses=2]
+ %tmp586 = icmp eq i32 %k.4342.0, 0 ; <i1> [#uses=1]
+ br i1 %tmp586, label %cond_true589, label %cond_false608
+
+cond_true589: ; preds = %bb583
+ br label %cond_next693
+
+cond_false608: ; preds = %bb583
+ br i1 false, label %cond_next661, label %cond_next693
+
+cond_next661: ; preds = %cond_false608
+ br label %cond_next693
+
+cond_next693: ; preds = %cond_next661, %cond_false608, %cond_true589
+ %tmp705 = getelementptr i32* null, i32 0 ; <i32*> [#uses=0]
+ %tmp707 = add i32 %k.4342.0, 1 ; <i32> [#uses=2]
+ %tmp711 = icmp sgt i32 %tmp707, 0 ; <i1> [#uses=1]
+ br i1 %tmp711, label %bb726.preheader, label %bb583
+
+bb726.preheader: ; preds = %cond_next693
+ ret void
+}
diff --git a/test/Transforms/LoopIndexSplit/Crash2-2007-08-17.ll b/test/Transforms/LoopIndexSplit/Crash2-2007-08-17.ll
new file mode 100644
index 0000000..76c30b3
--- /dev/null
+++ b/test/Transforms/LoopIndexSplit/Crash2-2007-08-17.ll
@@ -0,0 +1,59 @@
+; RUN: llvm-as < %s | opt -loop-index-split -disable-output -stats |& \
+; RUN: grep "loop-index-split" | count 1
+
+ %struct._edit_script = type { %struct._edit_script*, i32, i8 }
+
+define void @align_path(i8* %seq1, i8* %seq2, i32 %i1, i32 %j1, i32 %i2, i32 %j2, i32 %dist, %struct._edit_script** %head, %struct._edit_script** %tail, i32 %M, i32 %N) {
+entry:
+ br label %bb354
+
+bb354: ; preds = %bb511, %entry
+ br i1 false, label %bb495, label %bb368
+
+bb368: ; preds = %bb354
+ ret void
+
+bb495: ; preds = %bb495, %bb354
+ br i1 false, label %bb511, label %bb495
+
+bb511: ; preds = %bb495
+ br i1 false, label %xmalloc.exit69, label %bb354
+
+xmalloc.exit69: ; preds = %bb511
+ br i1 false, label %bb556, label %bb542.preheader
+
+bb542.preheader: ; preds = %xmalloc.exit69
+ ret void
+
+bb556: ; preds = %xmalloc.exit69
+ br label %bb583
+
+bb583: ; preds = %cond_next693, %bb556
+ %k.4342.0 = phi i32 [ %tmp707, %cond_next693 ], [ 0, %bb556 ] ; <i32> [#uses=2]
+ %tmp586 = icmp eq i32 %k.4342.0, 0 ; <i1> [#uses=1]
+ br i1 %tmp586, label %cond_true589, label %cond_false608
+
+cond_true589: ; preds = %bb583
+ br label %cond_next693
+
+cond_false608: ; preds = %bb583
+ br i1 false, label %bb645, label %cond_next693
+
+bb645: ; preds = %cond_false608
+ br i1 false, label %bb684, label %cond_next661
+
+cond_next661: ; preds = %bb645
+ br i1 false, label %bb684, label %cond_next693
+
+bb684: ; preds = %cond_next661, %bb645
+ br label %cond_next693
+
+cond_next693: ; preds = %bb684, %cond_next661, %cond_false608, %cond_true589
+ %tmp705 = getelementptr i32* null, i32 0 ; <i32*> [#uses=0]
+ %tmp707 = add i32 %k.4342.0, 1 ; <i32> [#uses=2]
+ %tmp711 = icmp sgt i32 %tmp707, 0 ; <i1> [#uses=1]
+ br i1 %tmp711, label %bb726.preheader, label %bb583
+
+bb726.preheader: ; preds = %cond_next693
+ ret void
+}
diff --git a/test/Transforms/LoopIndexSplit/OneIterLoop-2007-08-17.ll b/test/Transforms/LoopIndexSplit/OneIterLoop-2007-08-17.ll
new file mode 100644
index 0000000..fb2cbad
--- /dev/null
+++ b/test/Transforms/LoopIndexSplit/OneIterLoop-2007-08-17.ll
@@ -0,0 +1,61 @@
+; Loop is elimianted
+; RUN: llvm-as < %s | opt -loop-index-split -disable-output -stats |& \
+; RUN: grep "loop-index-split" | count 1
+ %struct.anon = type { i32 }
+@S1 = external global i32 ; <i32*> [#uses=1]
+@W1 = external global i32 ; <i32*> [#uses=1]
+@Y = weak global [100 x %struct.anon] zeroinitializer, align 32 ; <[100 x %struct.anon]*> [#uses=1]
+@ti = external global i32 ; <i32*> [#uses=1]
+@T2 = external global [100 x [100 x i32]] ; <[100 x [100 x i32]]*> [#uses=1]
+@d = external global i32 ; <i32*> [#uses=1]
+@T1 = external global i32 ; <i32*> [#uses=2]
+@N2 = external global i32 ; <i32*> [#uses=2]
+
+define void @foo() {
+entry:
+ %tmp = load i32* @S1, align 4 ; <i32> [#uses=2]
+ %tmp266 = load i32* @N2, align 4 ; <i32> [#uses=1]
+ %tmp288 = icmp ult i32 %tmp, %tmp266 ; <i1> [#uses=1]
+ br i1 %tmp288, label %bb.preheader, label %return
+
+bb.preheader: ; preds = %entry
+ %tmp1 = load i32* @W1, align 4 ; <i32> [#uses=1]
+ %tmp13 = load i32* @ti, align 4 ; <i32> [#uses=1]
+ %tmp18 = load i32* @d, align 4 ; <i32> [#uses=1]
+ %tmp26 = load i32* @N2, align 4 ; <i32> [#uses=1]
+ %T1.promoted = load i32* @T1 ; <i32> [#uses=1]
+ br label %bb
+
+bb: ; preds = %bb.preheader, %bb25
+ %T1.tmp.1 = phi i32 [ %T1.promoted, %bb.preheader ], [ %T1.tmp.0, %bb25 ] ; <i32> [#uses=3]
+ %tj.01.0 = phi i32 [ %tmp24, %bb25 ], [ %tmp, %bb.preheader ] ; <i32> [#uses=4]
+ %tmp3 = icmp eq i32 %tj.01.0, %tmp1 ; <i1> [#uses=1]
+ br i1 %tmp3, label %cond_true, label %bb25
+
+cond_true: ; preds = %bb
+ %tmp7 = getelementptr [100 x %struct.anon]* @Y, i32 0, i32 %tj.01.0, i32 0 ; <i32*> [#uses=1]
+ %tmp8 = load i32* %tmp7, align 4 ; <i32> [#uses=1]
+ %tmp9 = icmp sgt i32 %tmp8, 0 ; <i1> [#uses=1]
+ br i1 %tmp9, label %cond_true12, label %bb25
+
+cond_true12: ; preds = %cond_true
+ %tmp16 = getelementptr [100 x [100 x i32]]* @T2, i32 0, i32 %tmp13, i32 %tj.01.0 ; <i32*> [#uses=1]
+ %tmp17 = load i32* %tmp16, align 4 ; <i32> [#uses=1]
+ %tmp19 = mul i32 %tmp18, %tmp17 ; <i32> [#uses=1]
+ %tmp21 = add i32 %tmp19, %T1.tmp.1 ; <i32> [#uses=1]
+ br label %bb25
+
+bb25: ; preds = %cond_true, %bb, %cond_true12
+ %T1.tmp.0 = phi i32 [ %T1.tmp.1, %bb ], [ %T1.tmp.1, %cond_true ], [ %tmp21, %cond_true12 ] ; <i32> [#uses=2]
+ %tmp24 = add i32 %tj.01.0, 1 ; <i32> [#uses=2]
+ %tmp28 = icmp ult i32 %tmp24, %tmp26 ; <i1> [#uses=1]
+ br i1 %tmp28, label %bb, label %return.loopexit
+
+return.loopexit: ; preds = %bb25
+ %T1.tmp.0.lcssa = phi i32 [ %T1.tmp.0, %bb25 ] ; <i32> [#uses=1]
+ store i32 %T1.tmp.0.lcssa, i32* @T1
+ br label %return
+
+return: ; preds = %return.loopexit, %entry
+ ret void
+}
diff --git a/test/Transforms/LoopIndexSplit/OneIterLoop2-2007-08-17.ll b/test/Transforms/LoopIndexSplit/OneIterLoop2-2007-08-17.ll
new file mode 100644
index 0000000..a1ee818
--- /dev/null
+++ b/test/Transforms/LoopIndexSplit/OneIterLoop2-2007-08-17.ll
@@ -0,0 +1,62 @@
+; Loop is elimianted. Save last value assignment.
+; RUN: llvm-as < %s | opt -loop-index-split -disable-output -stats |& \
+; RUN: grep "loop-index-split" | count 1
+
+ %struct.anon = type { i32 }
+@S1 = external global i32 ; <i32*> [#uses=1]
+@W1 = external global i32 ; <i32*> [#uses=1]
+@Y = weak global [100 x %struct.anon] zeroinitializer, align 32 ; <[100 x %struct.anon]*> [#uses=1]
+@ti = external global i32 ; <i32*> [#uses=1]
+@T2 = external global [100 x [100 x i32]] ; <[100 x [100 x i32]]*> [#uses=1]
+@d = external global i32 ; <i32*> [#uses=1]
+@T1 = external global i32 ; <i32*> [#uses=2]
+@N1 = external global i32 ; <i32*> [#uses=2]
+
+define void @foo() {
+entry:
+ %tmp = load i32* @S1, align 4 ; <i32> [#uses=2]
+ %tmp266 = load i32* @N1, align 4 ; <i32> [#uses=1]
+ %tmp288 = icmp ult i32 %tmp, %tmp266 ; <i1> [#uses=1]
+ br i1 %tmp288, label %bb.preheader, label %return
+
+bb.preheader: ; preds = %entry
+ %tmp1 = load i32* @W1, align 4 ; <i32> [#uses=1]
+ %tmp13 = load i32* @ti, align 4 ; <i32> [#uses=1]
+ %tmp18 = load i32* @d, align 4 ; <i32> [#uses=1]
+ %tmp26 = load i32* @N1, align 4 ; <i32> [#uses=1]
+ %T1.promoted = load i32* @T1 ; <i32> [#uses=1]
+ br label %bb
+
+bb: ; preds = %bb.preheader, %bb25
+ %T1.tmp.1 = phi i32 [ %T1.promoted, %bb.preheader ], [ %T1.tmp.0, %bb25 ] ; <i32> [#uses=3]
+ %tj.01.0 = phi i32 [ %tmp24, %bb25 ], [ %tmp, %bb.preheader ] ; <i32> [#uses=4]
+ %tmp24 = add i32 %tj.01.0, 1 ; <i32> [#uses=2]
+ %tmp3 = icmp eq i32 %tmp24, %tmp1 ; <i1> [#uses=1]
+ br i1 %tmp3, label %cond_true, label %bb25
+
+cond_true: ; preds = %bb
+ %tmp7 = getelementptr [100 x %struct.anon]* @Y, i32 0, i32 %tj.01.0, i32 0 ; <i32*> [#uses=1]
+ %tmp8 = load i32* %tmp7, align 4 ; <i32> [#uses=1]
+ %tmp9 = icmp sgt i32 %tmp8, 0 ; <i1> [#uses=1]
+ br i1 %tmp9, label %cond_true12, label %bb25
+
+cond_true12: ; preds = %cond_true
+ %tmp16 = getelementptr [100 x [100 x i32]]* @T2, i32 0, i32 %tmp13, i32 %tj.01.0 ; <i32*> [#uses=1]
+ %tmp17 = load i32* %tmp16, align 4 ; <i32> [#uses=1]
+ %tmp19 = mul i32 %tmp18, %tmp17 ; <i32> [#uses=1]
+ %tmp21 = add i32 %tmp19, %T1.tmp.1 ; <i32> [#uses=1]
+ br label %bb25
+
+bb25: ; preds = %cond_true, %bb, %cond_true12
+ %T1.tmp.0 = phi i32 [ %T1.tmp.1, %bb ], [ %T1.tmp.1, %cond_true ], [ %tmp21, %cond_true12 ] ; <i32> [#uses=2]
+ %tmp28 = icmp ult i32 %tmp24, %tmp26 ; <i1> [#uses=1]
+ br i1 %tmp28, label %bb, label %return.loopexit
+
+return.loopexit: ; preds = %bb25
+ %T1.tmp.0.lcssa = phi i32 [ %T1.tmp.0, %bb25 ] ; <i32> [#uses=1]
+ store i32 %T1.tmp.0.lcssa, i32* @T1
+ br label %return
+
+return: ; preds = %return.loopexit, %entry
+ ret void
+}
diff --git a/test/Transforms/LoopIndexSplit/OneIterLoop3-2007-08-17.ll b/test/Transforms/LoopIndexSplit/OneIterLoop3-2007-08-17.ll
new file mode 100644
index 0000000..9ca8923
--- /dev/null
+++ b/test/Transforms/LoopIndexSplit/OneIterLoop3-2007-08-17.ll
@@ -0,0 +1,35 @@
+; Loop is elimianted. Save last value assignments, including induction variable.
+; RUN: llvm-as < %s | opt -loop-index-split -disable-output -stats |& \
+; RUN: grep "loop-index-split" | count 1
+
+declare i32 @foo(i32)
+declare i32 @bar(i32, i32)
+
+define void @foobar(i32 %a, i32 %b) {
+entry:
+ br label %bb
+
+bb: ; preds = %cond_next, %entry
+ %i.01.0 = phi i32 [ 0, %entry ], [ %tmp8, %cond_next ] ; <i32> [#uses=3]
+ %tsum.16.0 = phi i32 [ 42, %entry ], [ %tsum.0, %cond_next ] ; <i32> [#uses=2]
+ %tmp1 = icmp eq i32 %i.01.0, 50 ; <i1> [#uses=1]
+ br i1 %tmp1, label %cond_true, label %cond_next
+
+cond_true: ; preds = %bb
+ %tmp4 = tail call i32 @foo( i32 %i.01.0 ) ; <i32> [#uses=1]
+ %tmp6 = add i32 %tmp4, %tsum.16.0 ; <i32> [#uses=1]
+ br label %cond_next
+
+cond_next: ; preds = %bb, %cond_true
+ %tsum.0 = phi i32 [ %tmp6, %cond_true ], [ %tsum.16.0, %bb ] ; <i32> [#uses=2]
+ %tmp8 = add i32 %i.01.0, 1 ; <i32> [#uses=3]
+ %tmp11 = icmp slt i32 %tmp8, 100 ; <i1> [#uses=1]
+ br i1 %tmp11, label %bb, label %bb14
+
+bb14: ; preds = %cond_next
+ %tmp8.lcssa = phi i32 [ %tmp8, %cond_next ] ; <i32> [#uses=1]
+ %tsum.0.lcssa = phi i32 [ %tsum.0, %cond_next ] ; <i32> [#uses=1]
+ %tmp17 = tail call i32 @bar( i32 %tmp8.lcssa, i32 %tsum.0.lcssa ) ; <i32> [#uses=0]
+ ret void
+}
+
diff --git a/test/Transforms/LoopIndexSplit/SaveLastValue-2007-08-17.ll b/test/Transforms/LoopIndexSplit/SaveLastValue-2007-08-17.ll
new file mode 100644
index 0000000..e19f22a
--- /dev/null
+++ b/test/Transforms/LoopIndexSplit/SaveLastValue-2007-08-17.ll
@@ -0,0 +1,52 @@
+; Split loop. Save last value.
+; RUN: llvm-as < %s | opt -loop-index-split -disable-output -stats |& \
+; RUN: grep "loop-index-split" | count 1
+
+@k = external global i32 ; <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 ] ; <i32> [#uses=5]
+ %tsum.18.0 = phi i32 [ 42, %entry ], [ %tsum.013.1, %cond_next16 ] ; <i32> [#uses=3]
+ %tmp1 = icmp slt i32 %i.01.0, 50 ; <i1> [#uses=1]
+ br i1 %tmp1, label %cond_true, label %cond_false
+
+cond_true: ; preds = %bb
+ %tmp4 = tail call i32 @foo( i32 %i.01.0 ) ; <i32> [#uses=1]
+ %tmp6 = add i32 %tmp4, %tsum.18.0 ; <i32> [#uses=2]
+ %tmp914 = load i32* @k, align 4 ; <i32> [#uses=1]
+ %tmp1015 = icmp eq i32 %tmp914, 0 ; <i1> [#uses=1]
+ br i1 %tmp1015, label %cond_next16, label %cond_true13
+
+cond_false: ; preds = %bb
+ %tmp8 = tail call i32 @bar( i32 %i.01.0 ) ; <i32> [#uses=0]
+ %tmp9 = load i32* @k, align 4 ; <i32> [#uses=1]
+ %tmp10 = icmp eq i32 %tmp9, 0 ; <i1> [#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 ] ; <i32> [#uses=1]
+ %tmp15 = tail call i32 @bar( i32 %i.01.0 ) ; <i32> [#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 ] ; <i32> [#uses=2]
+ %tmp18 = add i32 %i.01.0, 1 ; <i32> [#uses=3]
+ %tmp21 = icmp slt i32 %tmp18, 100 ; <i1> [#uses=1]
+ br i1 %tmp21, label %bb, label %bb24
+
+bb24: ; preds = %cond_next16
+ %tmp18.lcssa = phi i32 [ %tmp18, %cond_next16 ] ; <i32> [#uses=1]
+ %tsum.013.1.lcssa = phi i32 [ %tsum.013.1, %cond_next16 ] ; <i32> [#uses=1]
+ %tmp27 = tail call i32 @t( i32 %tmp18.lcssa, i32 %tsum.013.1.lcssa ) ; <i32> [#uses=0]
+ ret void
+}
+
+declare i32 @foo(i32)
+
+declare i32 @bar(i32)
+
+declare i32 @t(i32, i32)
diff --git a/test/Transforms/LoopIndexSplit/dg.exp b/test/Transforms/LoopIndexSplit/dg.exp
new file mode 100644
index 0000000..879685c
--- /dev/null
+++ b/test/Transforms/LoopIndexSplit/dg.exp
@@ -0,0 +1,3 @@
+load_lib llvm.exp
+
+RunLLVMTests [lsort [glob -nocomplain $srcdir/$subdir/*.{ll,llx,c,cpp,tr}]]