aboutsummaryrefslogtreecommitdiffstats
path: root/test/Transforms/LoopStrengthReduce
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/LoopStrengthReduce')
-rw-r--r--test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll43
-rw-r--r--test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll43
-rw-r--r--test/Transforms/LoopStrengthReduce/2011-10-06-ReusePhi.ll53
-rw-r--r--test/Transforms/LoopStrengthReduce/2011-10-13-SCEVChain.ll111
-rw-r--r--test/Transforms/LoopStrengthReduce/2011-10-14-IntPtr.ll27
-rw-r--r--test/Transforms/LoopStrengthReduce/invariant_value_first.ll2
-rw-r--r--test/Transforms/LoopStrengthReduce/invariant_value_first_arg.ll2
-rw-r--r--test/Transforms/LoopStrengthReduce/ops_after_indvar.ll2
-rw-r--r--test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll14
-rw-r--r--test/Transforms/LoopStrengthReduce/var_stride_used_by_compare.ll2
10 files changed, 288 insertions, 11 deletions
diff --git a/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll b/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll
new file mode 100644
index 0000000000..5d9ed64ef4
--- /dev/null
+++ b/test/Transforms/LoopStrengthReduce/2011-07-20-DoubleIV.ll
@@ -0,0 +1,43 @@
+; RUN: opt < %s -loop-reduce -S | FileCheck %s
+;
+; Test LSR's OptimizeShadowIV. Handle a floating-point IV with a
+; nonzero initial value.
+; rdar://9786536
+
+; First, make sure LSR doesn't crash on an empty IVUsers list.
+; CHECK: @dummyIV
+; CHECK-NOT: phi
+; CHECK-NOT: sitofp
+; CHECK: br
+define void @dummyIV() nounwind {
+entry:
+ br label %loop
+
+loop:
+ %i.01 = phi i32 [ -39, %entry ], [ %inc, %loop ]
+ %conv = sitofp i32 %i.01 to double
+ %inc = add nsw i32 %i.01, 1
+ br i1 undef, label %loop, label %for.end
+
+for.end:
+ unreachable
+}
+
+; Now check that the computed double constant is correct.
+; CHECK: @doubleIV
+; CHECK: phi double [ -3.900000e+01, %entry ]
+; CHECK: br
+define void @doubleIV() nounwind {
+entry:
+ br label %loop
+
+loop:
+ %i.01 = phi i32 [ -39, %entry ], [ %inc, %loop ]
+ %conv = sitofp i32 %i.01 to double
+ %div = fdiv double %conv, 4.000000e+01
+ %inc = add nsw i32 %i.01, 1
+ br i1 undef, label %loop, label %for.end
+
+for.end:
+ unreachable
+}
diff --git a/test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll b/test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll
new file mode 100644
index 0000000000..a6996a81fb
--- /dev/null
+++ b/test/Transforms/LoopStrengthReduce/2011-10-03-CritEdgeMerge.ll
@@ -0,0 +1,43 @@
+; RUN: opt -loop-reduce -S < %s | FileCheck %s
+;
+; Test LSR's use of SplitCriticalEdge during phi rewriting.
+; Verify that identical edges are merged. rdar://problem/6453893
+
+target triple = "x86-apple-darwin"
+
+; CHECK: @test
+; CHECK: bb89:
+; CHECK: phi i8* [ %lsr.iv.next1, %bbA.bb89_crit_edge ], [ %lsr.iv.next1, %bbB.bb89_crit_edge ]{{$}}
+
+define i8* @test() {
+entry:
+ br label %loop
+
+loop:
+ %rec = phi i32 [ %next, %loop ], [ 0, %entry ]
+ %next = add i32 %rec, 1
+ %tmp75 = getelementptr i8* null, i32 %next
+ br i1 false, label %loop, label %loopexit
+
+loopexit:
+ br i1 false, label %bbA, label %bbB
+
+bbA:
+ switch i32 0, label %bb89 [
+ i32 47, label %bb89
+ i32 58, label %bb89
+ ]
+
+bbB:
+ switch i8 0, label %bb89 [
+ i8 47, label %bb89
+ i8 58, label %bb89
+ ]
+
+bb89:
+ %tmp75phi = phi i8* [ %tmp75, %bbA ], [ %tmp75, %bbA ], [ %tmp75, %bbA ], [ %tmp75, %bbB ], [ %tmp75, %bbB ], [ %tmp75, %bbB ]
+ br label %exit
+
+exit:
+ ret i8* %tmp75phi
+}
diff --git a/test/Transforms/LoopStrengthReduce/2011-10-06-ReusePhi.ll b/test/Transforms/LoopStrengthReduce/2011-10-06-ReusePhi.ll
new file mode 100644
index 0000000000..1ee9bb409d
--- /dev/null
+++ b/test/Transforms/LoopStrengthReduce/2011-10-06-ReusePhi.ll
@@ -0,0 +1,53 @@
+; RUN: opt -loop-reduce -S < %s | FileCheck %s
+;
+; Test LSR's intelligence regarding phi reuse.
+; Verify that scaled GEPs are not reused. rdar://5064068
+
+target triple = "x86-apple-darwin"
+
+; CHECK: @test
+; multiplies are hoisted out of the loop
+; CHECK: while.body.lr.ph:
+; CHECK: mul i64
+; CHECK: mul i64
+; GEPs are ugly
+; CHECK: while.body:
+; CHECK: phi
+; CHECK: phi
+; CHECK: phi
+; CHECK: phi
+; CHECK-NOT: phi
+; CHECK: bitcast float* {{.*}} to i8*
+; CHECK: bitcast float* {{.*}} to i8*
+; CHECK: getelementptr i8*
+; CHECK: getelementptr i8*
+
+define float @test(float* nocapture %A, float* nocapture %B, i32 %N, i32 %IA, i32 %IB) nounwind uwtable readonly ssp {
+entry:
+ %cmp1 = icmp sgt i32 %N, 0
+ br i1 %cmp1, label %while.body.lr.ph, label %while.end
+
+while.body.lr.ph: ; preds = %entry
+ %idx.ext = sext i32 %IA to i64
+ %idx.ext2 = sext i32 %IB to i64
+ br label %while.body
+
+while.body: ; preds = %while.body.lr.ph, %while.body
+ %A.addr.05 = phi float* [ %A, %while.body.lr.ph ], [ %add.ptr, %while.body ]
+ %B.addr.04 = phi float* [ %B, %while.body.lr.ph ], [ %add.ptr3, %while.body ]
+ %N.addr.03 = phi i32 [ %N, %while.body.lr.ph ], [ %sub, %while.body ]
+ %Sum0.02 = phi float [ 0.000000e+00, %while.body.lr.ph ], [ %add, %while.body ]
+ %0 = load float* %A.addr.05, align 4
+ %1 = load float* %B.addr.04, align 4
+ %mul = fmul float %0, %1
+ %add = fadd float %Sum0.02, %mul
+ %add.ptr = getelementptr inbounds float* %A.addr.05, i64 %idx.ext
+ %add.ptr3 = getelementptr inbounds float* %B.addr.04, i64 %idx.ext2
+ %sub = add nsw i32 %N.addr.03, -1
+ %cmp = icmp sgt i32 %sub, 0
+ br i1 %cmp, label %while.body, label %while.end
+
+while.end: ; preds = %while.body, %entry
+ %Sum0.0.lcssa = phi float [ 0.000000e+00, %entry ], [ %add, %while.body ]
+ ret float %Sum0.0.lcssa
+}
diff --git a/test/Transforms/LoopStrengthReduce/2011-10-13-SCEVChain.ll b/test/Transforms/LoopStrengthReduce/2011-10-13-SCEVChain.ll
new file mode 100644
index 0000000000..4718529bfd
--- /dev/null
+++ b/test/Transforms/LoopStrengthReduce/2011-10-13-SCEVChain.ll
@@ -0,0 +1,111 @@
+; RUN: opt -loop-reduce -S < %s | FileCheck %s
+;
+; Test TransformForPostIncUse and LSR's expansion of expressions in
+; post-inc form to ensure the implementation can handle expressions
+; DAGs, not just trees.
+
+target triple = "x86_64-apple-darwin"
+
+; Verify that -loop-reduce runs without "hanging" and reuses post-inc
+; expansions.
+; CHECK: @test
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK: icmp
+; CHECK-NOT: icmp
+define void @test(i8* %base, i32 %a0) nounwind {
+entry:
+ br label %bb1
+bb1:
+ %n0 = sub i32 0, %a0
+ %t0 = icmp ugt i32 %n0, -4
+ %m0 = select i1 %t0, i32 %n0, i32 -4
+ %a1 = add i32 %m0, %a0
+ %n1 = sub i32 0, %a1
+ %t1 = icmp ugt i32 %n1, -4
+ %m1 = select i1 %t1, i32 %n1, i32 -4
+ %a2 = add i32 %m1, %a1
+ %n2 = sub i32 0, %a2
+ %t2 = icmp ugt i32 %n2, -4
+ %m2 = select i1 %t2, i32 %n2, i32 -4
+ %a3 = add i32 %m2, %a2
+ %n3 = sub i32 0, %a3
+ %t3 = icmp ugt i32 %n3, -4
+ %m3 = select i1 %t3, i32 %n3, i32 -4
+ %a4 = add i32 %m3, %a3
+ %n4 = sub i32 0, %a4
+ %t4 = icmp ugt i32 %n4, -4
+ %m4 = select i1 %t4, i32 %n4, i32 -4
+ %a5 = add i32 %m4, %a4
+ %n5 = sub i32 0, %a5
+ %t5 = icmp ugt i32 %n5, -4
+ %m5 = select i1 %t5, i32 %n5, i32 -4
+ %a6 = add i32 %m5, %a5
+ %n6 = sub i32 0, %a6
+ %t6 = icmp ugt i32 %n6, -4
+ %m6 = select i1 %t6, i32 %n6, i32 -4
+ %a7 = add i32 %m6, %a6
+ %n7 = sub i32 0, %a7
+ %t7 = icmp ugt i32 %n7, -4
+ %m7 = select i1 %t7, i32 %n7, i32 -4
+ %a8 = add i32 %m7, %a7
+ %n8 = sub i32 0, %a8
+ %t8 = icmp ugt i32 %n8, -4
+ %m8 = select i1 %t8, i32 %n8, i32 -4
+ %a9 = add i32 %m8, %a8
+ %n9 = sub i32 0, %a9
+ %t9 = icmp ugt i32 %n9, -4
+ %m9 = select i1 %t9, i32 %n9, i32 -4
+ %a10 = add i32 %m9, %a9
+ %n10 = sub i32 0, %a10
+ %t10 = icmp ugt i32 %n10, -4
+ %m10 = select i1 %t10, i32 %n10, i32 -4
+ %a11 = add i32 %m10, %a10
+ %n11 = sub i32 0, %a11
+ %t11 = icmp ugt i32 %n11, -4
+ %m11 = select i1 %t11, i32 %n11, i32 -4
+ %a12 = add i32 %m11, %a11
+ %n12 = sub i32 0, %a12
+ %t12 = icmp ugt i32 %n12, -4
+ %m12 = select i1 %t12, i32 %n12, i32 -4
+ %a13 = add i32 %m12, %a12
+ %n13 = sub i32 0, %a13
+ %t13 = icmp ugt i32 %n13, -4
+ %m13 = select i1 %t13, i32 %n13, i32 -4
+ %a14 = add i32 %m13, %a13
+ %n14 = sub i32 0, %a14
+ %t14 = icmp ugt i32 %n14, -4
+ %m14 = select i1 %t14, i32 %n14, i32 -4
+ %a15 = add i32 %m14, %a14
+ %n15 = sub i32 0, %a15
+ %t15 = icmp ugt i32 %n15, -4
+ %m15 = select i1 %t15, i32 %n15, i32 -4
+ %a16 = add i32 %m15, %a15
+ %gep = getelementptr i8* %base, i32 %a16
+ %ofs = add i32 %a16, 4
+ %limit = getelementptr i8* %base, i32 %ofs
+ br label %loop
+
+loop:
+ %iv = phi i8* [ %gep, %bb1 ], [ %inc, %loop ]
+ %inc = getelementptr inbounds i8* %iv, i64 1
+ %exitcond = icmp eq i8* %inc, %limit
+ br i1 %exitcond, label %loop, label %exit
+
+exit:
+ ret void
+}
diff --git a/test/Transforms/LoopStrengthReduce/2011-10-14-IntPtr.ll b/test/Transforms/LoopStrengthReduce/2011-10-14-IntPtr.ll
new file mode 100644
index 0000000000..60cc7a5163
--- /dev/null
+++ b/test/Transforms/LoopStrengthReduce/2011-10-14-IntPtr.ll
@@ -0,0 +1,27 @@
+; RUN: opt -loop-reduce -S < %s | FileCheck %s
+;
+; Test SCEVExpander reusing a phi->gep->phi IV when SCEV "wrongly"
+; reports the expression as an IntegerTy.
+
+target triple = "x86_64-apple-darwin"
+
+; CHECK: @test
+; CHECK: phi
+; CHECK-NOT: phi
+define void @test(i32 %rowStride) ssp align 2 {
+entry:
+ %cond = select i1 undef, i32 %rowStride, i32 4
+ br label %for.end
+
+for.end.critedge: ; preds = %for.end
+ br label %for.end
+
+for.end: ; preds = %for.end.critedge, %entry
+ br i1 undef, label %for.body83, label %for.end.critedge
+
+for.body83: ; preds = %for.body83, %for.end
+ %ptr.0157 = phi i8* [ %add.ptr96, %for.body83 ], [ null, %for.end ]
+ store i8 undef, i8* %ptr.0157, align 1
+ %add.ptr96 = getelementptr inbounds i8* %ptr.0157, i32 %cond
+ br label %for.body83
+}
diff --git a/test/Transforms/LoopStrengthReduce/invariant_value_first.ll b/test/Transforms/LoopStrengthReduce/invariant_value_first.ll
index 986a55a3f6..2ca678761f 100644
--- a/test/Transforms/LoopStrengthReduce/invariant_value_first.ll
+++ b/test/Transforms/LoopStrengthReduce/invariant_value_first.ll
@@ -2,7 +2,7 @@
; RUN: opt < %s -loop-reduce -S | \
; RUN: not grep {getelementptr.*%outer.*%INDVAR}
-target datalayout = "e-p:32:32:32-n:8:16:32"
+target datalayout = "e-p:32:32:32-n8:16:32"
declare i1 @pred()
declare i32 @foo()
diff --git a/test/Transforms/LoopStrengthReduce/invariant_value_first_arg.ll b/test/Transforms/LoopStrengthReduce/invariant_value_first_arg.ll
index 1d43961c35..86c4d915a0 100644
--- a/test/Transforms/LoopStrengthReduce/invariant_value_first_arg.ll
+++ b/test/Transforms/LoopStrengthReduce/invariant_value_first_arg.ll
@@ -2,7 +2,7 @@
; RUN: opt < %s -loop-reduce -S | \
; RUN: not grep {getelementptr.*%outer.*%INDVAR}
-target datalayout = "e-p:32:32:32-n:32"
+target datalayout = "e-p:32:32:32-n32"
declare i1 @pred()
define void @test([10000 x i32]* %P, i32 %outer) {
diff --git a/test/Transforms/LoopStrengthReduce/ops_after_indvar.ll b/test/Transforms/LoopStrengthReduce/ops_after_indvar.ll
index 00bd068d0b..ec55179d64 100644
--- a/test/Transforms/LoopStrengthReduce/ops_after_indvar.ll
+++ b/test/Transforms/LoopStrengthReduce/ops_after_indvar.ll
@@ -3,7 +3,7 @@
; RUN: opt < %s -loop-reduce -S | not grep INDVAR
-target datalayout = "e-p:32:32:32-n:32"
+target datalayout = "e-p:32:32:32-n32"
declare i1 @pred()
diff --git a/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll b/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll
index 294c090419..27609157ec 100644
--- a/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll
+++ b/test/Transforms/LoopStrengthReduce/post-inc-icmpzero.ll
@@ -4,15 +4,15 @@
; LSR should property handle the post-inc offset when folding the
; non-IV operand of an icmp into the IV.
-; CHECK: %tmp2 = sub i64 %sub.ptr.lhs.cast, %sub.ptr.rhs.cast
-; CHECK: %tmp3 = lshr i64 %tmp2, 1
-; CHECK: %tmp4 = mul i64 %tmp3, 2
+; CHECK: %5 = sub i64 %sub.ptr.lhs.cast, %sub.ptr.rhs.cast
+; CHECK: %6 = lshr i64 %5, 1
+; CHECK: %7 = mul i64 %6, 2
; CHECK: br label %for.body
; CHECK: for.body:
-; CHECK: %lsr.iv5 = phi i64 [ %lsr.iv.next, %for.body ], [ %tmp4, %for.body.lr.ph ]
-; CHECK: %lsr.iv.next = add i64 %lsr.iv5, -2
-; CHECK: %lsr.iv.next6 = inttoptr i64 %lsr.iv.next to i16*
-; CHECK: %cmp27 = icmp eq i16* %lsr.iv.next6, null
+; CHECK: %lsr.iv2 = phi i64 [ %lsr.iv.next, %for.body ], [ %7, %for.body.lr.ph ]
+; CHECK: %lsr.iv.next = add i64 %lsr.iv2, -2
+; CHECK: %lsr.iv.next3 = inttoptr i64 %lsr.iv.next to i16*
+; CHECK: %cmp27 = icmp eq i16* %lsr.iv.next3, null
target datalayout = "e-p:64:64:64-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:64:64-f32:32:32-f64:64:64-v64:64:64-v128:128:128-a0:0:64-s0:64:64-f80:128:128-n8:16:32:64"
target triple = "x86_64-unknown-linux-gnu"
diff --git a/test/Transforms/LoopStrengthReduce/var_stride_used_by_compare.ll b/test/Transforms/LoopStrengthReduce/var_stride_used_by_compare.ll
index 7547d83629..64ef4f951f 100644
--- a/test/Transforms/LoopStrengthReduce/var_stride_used_by_compare.ll
+++ b/test/Transforms/LoopStrengthReduce/var_stride_used_by_compare.ll
@@ -9,7 +9,7 @@
; mul uint %i, 3
-target datalayout = "e-p:32:32-n:32"
+target datalayout = "e-p:32:32-n32"
target triple = "i686-apple-darwin8"
@flags2 = external global [8193 x i8], align 32 ; <[8193 x i8]*> [#uses=1]