aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDevang Patel <dpatel@apple.com>2008-12-04 21:38:42 +0000
committerDevang Patel <dpatel@apple.com>2008-12-04 21:38:42 +0000
commit3831005eb1ef41802c970244ba08d9df7d0eee9a (patch)
treeda14826899e10246d77f27a9dc2d99253ba3abcb /test
parent6002e993e045a36f90df076fa3c8a2127edb66d5 (diff)
downloadexternal_llvm-3831005eb1ef41802c970244ba08d9df7d0eee9a.zip
external_llvm-3831005eb1ef41802c970244ba08d9df7d0eee9a.tar.gz
external_llvm-3831005eb1ef41802c970244ba08d9df7d0eee9a.tar.bz2
Rewrite code that 1) filters loops and 2) calculates new loop bounds.
This fixes many bugs. I will add more test cases in a separate check-in. Some day, the code that manipulates CFG and updates dom. info could use refactoring help. git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@60554 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'test')
-rw-r--r--test/Transforms/LoopIndexSplit/2007-09-24-UpdateIterationSpace.ll2
-rw-r--r--test/Transforms/LoopIndexSplit/2007-09-25-UpdateIterationSpace-2.ll17
-rw-r--r--test/Transforms/LoopIndexSplit/2008-10-10-OneIteration.ll42
-rw-r--r--test/Transforms/LoopIndexSplit/OneIterLoop-2007-08-17.ll22
-rw-r--r--test/Transforms/LoopIndexSplit/OneIterLoop2-2007-08-17.ll23
5 files changed, 60 insertions, 46 deletions
diff --git a/test/Transforms/LoopIndexSplit/2007-09-24-UpdateIterationSpace.ll b/test/Transforms/LoopIndexSplit/2007-09-24-UpdateIterationSpace.ll
index b648cec..ec29847 100644
--- a/test/Transforms/LoopIndexSplit/2007-09-24-UpdateIterationSpace.ll
+++ b/test/Transforms/LoopIndexSplit/2007-09-24-UpdateIterationSpace.ll
@@ -13,7 +13,7 @@ bb.preheader: ; preds = %entry
br label %bb
bb: ; preds = %bb.preheader, %cond_next45
- %i.01.0 = phi i32 [ %tmp47, %cond_next45 ], [ %xmin, %bb.preheader ] ; <i32> [#uses=6]
+ %i.01.0 = phi i32 [ %tmp47, %cond_next45 ], [ 0, %bb.preheader ] ; <i32> [#uses=6]
%tmp2 = icmp sgt i32 %i.01.0, -1 ; <i1> [#uses=1]
%tmp6 = icmp slt i32 %i.01.0, %ndat ; <i1> [#uses=1]
%bothcond = and i1 %tmp2, %tmp6 ; <i1> [#uses=1]
diff --git a/test/Transforms/LoopIndexSplit/2007-09-25-UpdateIterationSpace-2.ll b/test/Transforms/LoopIndexSplit/2007-09-25-UpdateIterationSpace-2.ll
index 06f9e11..7d93785 100644
--- a/test/Transforms/LoopIndexSplit/2007-09-25-UpdateIterationSpace-2.ll
+++ b/test/Transforms/LoopIndexSplit/2007-09-25-UpdateIterationSpace-2.ll
@@ -1,6 +1,7 @@
; PR714
; Update loop iteraton space to eliminate condition inside loop.
; RUN: llvm-as < %s | opt -loop-index-split | llvm-dis | not grep bothcond
+
define void @test(float* %x, i32 %ndat, float** %y, float %xcen, i32 %xmin, i32 %xmax, float %sigmal, float %contribution) {
entry:
%tmp5310 = icmp sgt i32 %xmin, %xmax ; <i1> [#uses=1]
@@ -12,9 +13,9 @@ bb.preheader: ; preds = %entry
%tmp3839 = fpext float %sigmal to double ; <double> [#uses=1]
br label %bb
-bb: ; preds = %bb.preheader, %cond_next45
- %i.01.0 = phi i32 [ %tmp47, %cond_next45 ], [ %xmin, %bb.preheader ] ; <i32> [#uses=4]
- %k.06.0 = phi i32 [ %tmp49, %cond_next45 ], [ 0, %bb.preheader ] ; <i32> [#uses=3]
+bb: ; preds = %cond_next45, %bb.preheader
+ %k.06.0 = phi i32 [ 0, %bb.preheader ], [ %indvar.next, %cond_next45 ] ; <i32> [#uses=4]
+ %i.01.0 = add i32 %k.06.0, %xmin ; <i32> [#uses=4]
%tmp2 = icmp sgt i32 %i.01.0, -1 ; <i1> [#uses=1]
%tmp6 = icmp slt i32 %i.01.0, %ndat ; <i1> [#uses=1]
%bothcond = and i1 %tmp2, %tmp6 ; <i1> [#uses=1]
@@ -24,7 +25,7 @@ cond_true9: ; preds = %bb
%tmp12 = getelementptr float* %x, i32 %i.01.0 ; <float*> [#uses=1]
%tmp13 = load float* %tmp12, align 4 ; <float> [#uses=1]
%tmp15 = sub float %xcen, %tmp13 ; <float> [#uses=1]
- %tmp16 = tail call float @fabsf( float %tmp15 ) ; <float> [#uses=1]
+ %tmp16 = tail call float @fabsf(float %tmp15) ; <float> [#uses=1]
%tmp18 = fdiv float %tmp16, %sigmal ; <float> [#uses=1]
%tmp21 = load float** %y, align 4 ; <float*> [#uses=2]
%tmp27 = getelementptr float* %tmp21, i32 %k.06.0 ; <float*> [#uses=1]
@@ -32,7 +33,7 @@ cond_true9: ; preds = %bb
%tmp2829 = fpext float %tmp28 to double ; <double> [#uses=1]
%tmp34 = sub float -0.000000e+00, %tmp18 ; <float> [#uses=1]
%tmp3435 = fpext float %tmp34 to double ; <double> [#uses=1]
- %tmp36 = tail call double @exp( double %tmp3435 ) ; <double> [#uses=1]
+ %tmp36 = tail call double @exp(double %tmp3435) ; <double> [#uses=1]
%tmp37 = mul double %tmp32, %tmp36 ; <double> [#uses=1]
%tmp40 = fdiv double %tmp37, %tmp3839 ; <double> [#uses=1]
%tmp41 = add double %tmp2829, %tmp40 ; <double> [#uses=1]
@@ -41,10 +42,10 @@ cond_true9: ; preds = %bb
store float %tmp4142, float* %tmp44, align 4
br label %cond_next45
-cond_next45: ; preds = %bb, %cond_true9
- %tmp47 = add i32 %i.01.0, 1 ; <i32> [#uses=2]
- %tmp49 = add i32 %k.06.0, 1 ; <i32> [#uses=1]
+cond_next45: ; preds = %cond_true9, %bb
+ %tmp47 = add i32 %i.01.0, 1 ; <i32> [#uses=1]
%tmp53 = icmp sgt i32 %tmp47, %xmax ; <i1> [#uses=1]
+ %indvar.next = add i32 %k.06.0, 1 ; <i32> [#uses=1]
br i1 %tmp53, label %return.loopexit, label %bb
return.loopexit: ; preds = %cond_next45
diff --git a/test/Transforms/LoopIndexSplit/2008-10-10-OneIteration.ll b/test/Transforms/LoopIndexSplit/2008-10-10-OneIteration.ll
index 7c0d207..417f091 100644
--- a/test/Transforms/LoopIndexSplit/2008-10-10-OneIteration.ll
+++ b/test/Transforms/LoopIndexSplit/2008-10-10-OneIteration.ll
@@ -1,4 +1,4 @@
-; RUN: llvm-as < %s | opt -loop-index-split | llvm-dis | grep sle | count 1
+; RUN: llvm-as < %s | opt -loop-index-split -stats -disable-output |& grep "1 loop-index-split"
; PR 2869
@w = external global [2 x [2 x i32]] ; <[2 x [2 x i32]]*> [#uses=5]
@@ -10,11 +10,11 @@ entry:
br label %bb1.i.outer
bb1.i.outer: ; preds = %bb5.i, %entry
- %i.0.reg2mem.0.ph.i.ph = phi i32 [ 0, %entry ], [ %4, %bb5.i ] ; <i32> [#uses=3]
+ %i.0.reg2mem.0.ph.i.ph = phi i32 [ 0, %entry ], [ %indvar.next1, %bb5.i ] ; <i32> [#uses=3]
br label %bb1.i
bb1.i: ; preds = %bb3.i, %bb1.i.outer
- %j.0.reg2mem.0.i = phi i32 [ %2, %bb3.i ], [ 0, %bb1.i.outer ] ; <i32> [#uses=3]
+ %j.0.reg2mem.0.i = phi i32 [ 0, %bb1.i.outer ], [ %indvar.next, %bb3.i ] ; <i32> [#uses=3]
%0 = icmp eq i32 %i.0.reg2mem.0.ph.i.ph, %j.0.reg2mem.0.i ; <i1> [#uses=1]
br i1 %0, label %bb2.i, label %bb3.i
@@ -24,34 +24,34 @@ bb2.i: ; preds = %bb1.i
br label %bb3.i
bb3.i: ; preds = %bb2.i, %bb1.i
- %2 = add i32 %j.0.reg2mem.0.i, 1 ; <i32> [#uses=2]
- %3 = icmp sgt i32 %2, 1 ; <i1> [#uses=1]
- br i1 %3, label %bb5.i, label %bb1.i
+ %indvar.next = add i32 %j.0.reg2mem.0.i, 1 ; <i32> [#uses=2]
+ %exitcond = icmp eq i32 %indvar.next, 2 ; <i1> [#uses=1]
+ br i1 %exitcond, label %bb5.i, label %bb1.i
bb5.i: ; preds = %bb3.i
- %4 = add i32 %i.0.reg2mem.0.ph.i.ph, 1 ; <i32> [#uses=2]
- %5 = icmp sgt i32 %4, 1 ; <i1> [#uses=1]
- br i1 %5, label %f.exit, label %bb1.i.outer
+ %indvar.next1 = add i32 %i.0.reg2mem.0.ph.i.ph, 1 ; <i32> [#uses=2]
+ %exitcond2 = icmp eq i32 %indvar.next1, 2 ; <i1> [#uses=1]
+ br i1 %exitcond2, label %f.exit, label %bb1.i.outer
f.exit: ; preds = %bb5.i
- %6 = load i32* getelementptr ([2 x [2 x i32]]* @w, i32 0, i32 0, i32 0), align 4 ; <i32> [#uses=1]
- %7 = icmp eq i32 %6, 1 ; <i1> [#uses=1]
- br i1 %7, label %bb, label %bb3
+ %2 = load i32* getelementptr ([2 x [2 x i32]]* @w, i32 0, i32 0, i32 0), align 4 ; <i32> [#uses=1]
+ %3 = icmp eq i32 %2, 1 ; <i1> [#uses=1]
+ br i1 %3, label %bb, label %bb3
bb: ; preds = %f.exit
- %8 = load i32* getelementptr ([2 x [2 x i32]]* @w, i32 0, i32 1, i32 1), align 4 ; <i32> [#uses=1]
- %9 = icmp eq i32 %8, 1 ; <i1> [#uses=1]
- br i1 %9, label %bb1, label %bb3
+ %4 = load i32* getelementptr ([2 x [2 x i32]]* @w, i32 0, i32 1, i32 1), align 4 ; <i32> [#uses=1]
+ %5 = icmp eq i32 %4, 1 ; <i1> [#uses=1]
+ br i1 %5, label %bb1, label %bb3
bb1: ; preds = %bb
- %10 = load i32* getelementptr ([2 x [2 x i32]]* @w, i32 0, i32 1, i32 0), align 4 ; <i32> [#uses=1]
- %11 = icmp eq i32 %10, 0 ; <i1> [#uses=1]
- br i1 %11, label %bb2, label %bb3
+ %6 = load i32* getelementptr ([2 x [2 x i32]]* @w, i32 0, i32 1, i32 0), align 4 ; <i32> [#uses=1]
+ %7 = icmp eq i32 %6, 0 ; <i1> [#uses=1]
+ br i1 %7, label %bb2, label %bb3
bb2: ; preds = %bb1
- %12 = load i32* getelementptr ([2 x [2 x i32]]* @w, i32 0, i32 0, i32 1), align 4 ; <i32> [#uses=1]
- %13 = icmp eq i32 %12, 0 ; <i1> [#uses=1]
- br i1 %13, label %bb4, label %bb3
+ %8 = load i32* getelementptr ([2 x [2 x i32]]* @w, i32 0, i32 0, i32 1), align 4 ; <i32> [#uses=1]
+ %9 = icmp eq i32 %8, 0 ; <i1> [#uses=1]
+ br i1 %9, label %bb4, label %bb3
bb3: ; preds = %bb2, %bb1, %bb, %f.exit
tail call void @abort() noreturn nounwind
diff --git a/test/Transforms/LoopIndexSplit/OneIterLoop-2007-08-17.ll b/test/Transforms/LoopIndexSplit/OneIterLoop-2007-08-17.ll
index fb2cbad..e98f699 100644
--- a/test/Transforms/LoopIndexSplit/OneIterLoop-2007-08-17.ll
+++ b/test/Transforms/LoopIndexSplit/OneIterLoop-2007-08-17.ll
@@ -13,7 +13,7 @@
define void @foo() {
entry:
- %tmp = load i32* @S1, align 4 ; <i32> [#uses=2]
+ %tmp = load i32* @S1, align 4 ; <i32> [#uses=4]
%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
@@ -22,13 +22,19 @@ 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]
+ %tmp26 = load i32* @N2, align 4 ; <i32> [#uses=2]
%T1.promoted = load i32* @T1 ; <i32> [#uses=1]
+ %tmp2 = add i32 %tmp, 1 ; <i32> [#uses=2]
+ %tmp4 = icmp ugt i32 %tmp2, %tmp26 ; <i1> [#uses=1]
+ %umax = select i1 %tmp4, i32 %tmp2, i32 %tmp26 ; <i32> [#uses=1]
+ %tmp5 = sub i32 0, %tmp ; <i32> [#uses=1]
+ %tmp6 = add i32 %umax, %tmp5 ; <i32> [#uses=1]
br label %bb
-bb: ; preds = %bb.preheader, %bb25
+bb: ; preds = %bb25, %bb.preheader
+ %indvar = phi i32 [ 0, %bb.preheader ], [ %indvar.next, %bb25 ] ; <i32> [#uses=2]
%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]
+ %tj.01.0 = add i32 %indvar, %tmp ; <i32> [#uses=3]
%tmp3 = icmp eq i32 %tj.01.0, %tmp1 ; <i1> [#uses=1]
br i1 %tmp3, label %cond_true, label %bb25
@@ -45,11 +51,11 @@ cond_true12: ; preds = %cond_true
%tmp21 = add i32 %tmp19, %T1.tmp.1 ; <i32> [#uses=1]
br label %bb25
-bb25: ; preds = %cond_true, %bb, %cond_true12
+bb25: ; preds = %cond_true12, %cond_true, %bb
%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
+ %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=2]
+ %exitcond = icmp ne i32 %indvar.next, %tmp6 ; <i1> [#uses=1]
+ br i1 %exitcond, label %bb, label %return.loopexit
return.loopexit: ; preds = %bb25
%T1.tmp.0.lcssa = phi i32 [ %T1.tmp.0, %bb25 ] ; <i32> [#uses=1]
diff --git a/test/Transforms/LoopIndexSplit/OneIterLoop2-2007-08-17.ll b/test/Transforms/LoopIndexSplit/OneIterLoop2-2007-08-17.ll
index a1ee818..31332bd 100644
--- a/test/Transforms/LoopIndexSplit/OneIterLoop2-2007-08-17.ll
+++ b/test/Transforms/LoopIndexSplit/OneIterLoop2-2007-08-17.ll
@@ -14,7 +14,7 @@
define void @foo() {
entry:
- %tmp = load i32* @S1, align 4 ; <i32> [#uses=2]
+ %tmp = load i32* @S1, align 4 ; <i32> [#uses=4]
%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
@@ -23,14 +23,20 @@ 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]
+ %tmp26 = load i32* @N1, align 4 ; <i32> [#uses=2]
%T1.promoted = load i32* @T1 ; <i32> [#uses=1]
+ %tmp2 = add i32 %tmp, 1 ; <i32> [#uses=2]
+ %tmp4 = icmp ugt i32 %tmp2, %tmp26 ; <i1> [#uses=1]
+ %umax = select i1 %tmp4, i32 %tmp2, i32 %tmp26 ; <i32> [#uses=1]
+ %tmp5 = sub i32 0, %tmp ; <i32> [#uses=1]
+ %tmp6 = add i32 %umax, %tmp5 ; <i32> [#uses=1]
br label %bb
-bb: ; preds = %bb.preheader, %bb25
+bb: ; preds = %bb25, %bb.preheader
+ %indvar = phi i32 [ 0, %bb.preheader ], [ %indvar.next, %bb25 ] ; <i32> [#uses=2]
%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]
+ %tj.01.0 = add i32 %indvar, %tmp ; <i32> [#uses=3]
+ %tmp24 = add i32 %tj.01.0, 1 ; <i32> [#uses=1]
%tmp3 = icmp eq i32 %tmp24, %tmp1 ; <i1> [#uses=1]
br i1 %tmp3, label %cond_true, label %bb25
@@ -47,10 +53,11 @@ cond_true12: ; preds = %cond_true
%tmp21 = add i32 %tmp19, %T1.tmp.1 ; <i32> [#uses=1]
br label %bb25
-bb25: ; preds = %cond_true, %bb, %cond_true12
+bb25: ; preds = %cond_true12, %cond_true, %bb
%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
+ %indvar.next = add i32 %indvar, 1 ; <i32> [#uses=2]
+ %exitcond = icmp ne i32 %indvar.next, %tmp6 ; <i1> [#uses=1]
+ br i1 %exitcond, label %bb, label %return.loopexit
return.loopexit: ; preds = %bb25
%T1.tmp.0.lcssa = phi i32 [ %T1.tmp.0, %bb25 ] ; <i32> [#uses=1]