summaryrefslogtreecommitdiff
path: root/test/Transforms/IndVarSimplify
diff options
context:
space:
mode:
Diffstat (limited to 'test/Transforms/IndVarSimplify')
-rw-r--r--test/Transforms/IndVarSimplify/casted-argument.ll2
-rw-r--r--test/Transforms/IndVarSimplify/crash.ll2
-rw-r--r--test/Transforms/IndVarSimplify/eliminate-comparison.ll108
-rw-r--r--test/Transforms/IndVarSimplify/eliminate-max.ll52
-rw-r--r--test/Transforms/IndVarSimplify/eliminate-rem.ll121
-rw-r--r--test/Transforms/IndVarSimplify/udiv.ll162
6 files changed, 445 insertions, 2 deletions
diff --git a/test/Transforms/IndVarSimplify/casted-argument.ll b/test/Transforms/IndVarSimplify/casted-argument.ll
index dfefe1dc5bbe..a5e002b4578f 100644
--- a/test/Transforms/IndVarSimplify/casted-argument.ll
+++ b/test/Transforms/IndVarSimplify/casted-argument.ll
@@ -47,4 +47,4 @@ if.end54: ; preds = %if.end54, %if.else
declare void @bcopy(i8* nocapture) nounwind
-declare void @bcopy_4038(i8*, i32) nounwind
+declare void @bcopy_4038(i8*, i8*, i32) nounwind
diff --git a/test/Transforms/IndVarSimplify/crash.ll b/test/Transforms/IndVarSimplify/crash.ll
index 14f79fefb180..ab438334c660 100644
--- a/test/Transforms/IndVarSimplify/crash.ll
+++ b/test/Transforms/IndVarSimplify/crash.ll
@@ -16,4 +16,4 @@ define void @t2(i1* %P) nounwind {
; <label>:6 ; preds = %1
ret void
-} \ No newline at end of file
+}
diff --git a/test/Transforms/IndVarSimplify/eliminate-comparison.ll b/test/Transforms/IndVarSimplify/eliminate-comparison.ll
new file mode 100644
index 000000000000..953bbdff5c62
--- /dev/null
+++ b/test/Transforms/IndVarSimplify/eliminate-comparison.ll
@@ -0,0 +1,108 @@
+; RUN: opt -indvars -S < %s | FileCheck %s
+
+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"
+
+@X = external global [0 x double]
+
+; Indvars should be able to simplify simple comparisons involving
+; induction variables.
+
+; CHECK: @foo
+; CHECK: %cond = and i1 %tobool.not, true
+
+define void @foo(i64 %n, i32* nocapture %p) nounwind {
+entry:
+ %cmp9 = icmp sgt i64 %n, 0
+ br i1 %cmp9, label %pre, label %return
+
+pre:
+ %t3 = load i32* %p
+ %tobool.not = icmp ne i32 %t3, 0
+ br label %loop
+
+loop:
+ %i = phi i64 [ 0, %pre ], [ %inc, %for.inc ]
+ %cmp6 = icmp slt i64 %i, %n
+ %cond = and i1 %tobool.not, %cmp6
+ br i1 %cond, label %if.then, label %for.inc
+
+if.then:
+ %arrayidx = getelementptr [0 x double]* @X, i64 0, i64 %i
+ store double 3.200000e+00, double* %arrayidx
+ br label %for.inc
+
+for.inc:
+ %inc = add nsw i64 %i, 1
+ %exitcond = icmp sge i64 %inc, %n
+ br i1 %exitcond, label %return, label %loop
+
+return:
+ ret void
+}
+
+; Don't eliminate an icmp that's contributing to the loop exit test though.
+
+; CHECK: @_ZNK4llvm5APInt3ultERKS0_
+; CHECK: %tmp99 = icmp sgt i32 %i, -1
+
+define i32 @_ZNK4llvm5APInt3ultERKS0_(i32 %tmp2.i1, i64** %tmp65, i64** %tmp73, i64** %tmp82, i64** %tmp90) {
+entry:
+ br label %bb18
+
+bb13:
+ %tmp66 = load i64** %tmp65, align 4
+ %tmp68 = getelementptr inbounds i64* %tmp66, i32 %i
+ %tmp69 = load i64* %tmp68, align 4
+ %tmp74 = load i64** %tmp73, align 4
+ %tmp76 = getelementptr inbounds i64* %tmp74, i32 %i
+ %tmp77 = load i64* %tmp76, align 4
+ %tmp78 = icmp ugt i64 %tmp69, %tmp77
+ br i1 %tmp78, label %bb20.loopexit, label %bb15
+
+bb15:
+ %tmp83 = load i64** %tmp82, align 4
+ %tmp85 = getelementptr inbounds i64* %tmp83, i32 %i
+ %tmp86 = load i64* %tmp85, align 4
+ %tmp91 = load i64** %tmp90, align 4
+ %tmp93 = getelementptr inbounds i64* %tmp91, i32 %i
+ %tmp94 = load i64* %tmp93, align 4
+ %tmp95 = icmp ult i64 %tmp86, %tmp94
+ br i1 %tmp95, label %bb20.loopexit, label %bb17
+
+bb17:
+ %tmp97 = add nsw i32 %i, -1
+ br label %bb18
+
+bb18:
+ %i = phi i32 [ %tmp2.i1, %entry ], [ %tmp97, %bb17 ]
+ %tmp99 = icmp sgt i32 %i, -1
+ br i1 %tmp99, label %bb13, label %bb20.loopexit
+
+bb20.loopexit:
+ %tmp.0.ph = phi i32 [ 0, %bb18 ], [ 1, %bb15 ], [ 0, %bb13 ]
+ ret i32 %tmp.0.ph
+}
+
+; Indvars should eliminate the icmp here.
+
+; CHECK: @func_10
+; CHECK-NOT: icmp
+; CHECK: ret void
+
+define void @func_10() nounwind {
+entry:
+ br label %loop
+
+loop:
+ %i = phi i32 [ %i.next, %loop ], [ 0, %entry ]
+ %t0 = icmp slt i32 %i, 0
+ %t1 = zext i1 %t0 to i32
+ %t2 = add i32 %t1, %i
+ %u3 = zext i32 %t2 to i64
+ store i64 %u3, i64* null
+ %i.next = add i32 %i, 1
+ br i1 undef, label %loop, label %return
+
+return:
+ ret void
+}
diff --git a/test/Transforms/IndVarSimplify/eliminate-max.ll b/test/Transforms/IndVarSimplify/eliminate-max.ll
new file mode 100644
index 000000000000..c25bd0e35418
--- /dev/null
+++ b/test/Transforms/IndVarSimplify/eliminate-max.ll
@@ -0,0 +1,52 @@
+; RUN: opt < %s -S -indvars | grep {= icmp} | count 3
+; PR4914.ll
+
+; Indvars should be able to do range analysis and eliminate icmps.
+; There are two here which cannot be eliminated.
+; There's one that icmp which can be eliminated and which indvars currently
+; cannot eliminate, because it requires analyzing more than just the
+; range of the induction variable.
+
+@0 = private constant [4 x i8] c"%d\0A\00", align 1 ; <[4 x i8]*> [#uses=1]
+
+define i32 @main() nounwind {
+bb:
+ br label %bb1
+
+bb1: ; preds = %bb14, %bb
+ %t = phi i32 [ 0, %bb ], [ %t19, %bb14 ] ; <i32> [#uses=5]
+ %t2 = phi i32 [ 0, %bb ], [ %t18, %bb14 ] ; <i32> [#uses=1]
+ %t3 = icmp slt i32 %t, 0 ; <i1> [#uses=1]
+ br i1 %t3, label %bb7, label %bb4
+
+bb4: ; preds = %bb1
+ %t5 = icmp sgt i32 %t, 255 ; <i1> [#uses=1]
+ %t6 = select i1 %t5, i32 255, i32 %t ; <i32> [#uses=1]
+ br label %bb7
+
+bb7: ; preds = %bb4, %bb1
+ %t8 = phi i32 [ %t6, %bb4 ], [ 0, %bb1 ] ; <i32> [#uses=1]
+ %t9 = sub i32 0, %t ; <i32> [#uses=3]
+ %t10 = icmp slt i32 %t9, 0 ; <i1> [#uses=1]
+ br i1 %t10, label %bb14, label %bb11
+
+bb11: ; preds = %bb7
+ %t12 = icmp sgt i32 %t9, 255 ; <i1> [#uses=1]
+ %t13 = select i1 %t12, i32 255, i32 %t9 ; <i32> [#uses=1]
+ br label %bb14
+
+bb14: ; preds = %bb11, %bb7
+ %t15 = phi i32 [ %t13, %bb11 ], [ 0, %bb7 ] ; <i32> [#uses=1]
+ %t16 = add nsw i32 %t2, 255 ; <i32> [#uses=1]
+ %t17 = add nsw i32 %t16, %t8 ; <i32> [#uses=1]
+ %t18 = add nsw i32 %t17, %t15 ; <i32> [#uses=2]
+ %t19 = add nsw i32 %t, 1 ; <i32> [#uses=2]
+ %t20 = icmp slt i32 %t19, 1000000000 ; <i1> [#uses=1]
+ br i1 %t20, label %bb1, label %bb21
+
+bb21: ; preds = %bb14
+ %t22 = call i32 (i8*, ...)* @printf(i8* noalias getelementptr inbounds ([4 x i8]* @0, i32 0, i32 0), i32 %t18) nounwind
+ ret i32 0
+}
+
+declare i32 @printf(i8* noalias nocapture, ...) nounwind
diff --git a/test/Transforms/IndVarSimplify/eliminate-rem.ll b/test/Transforms/IndVarSimplify/eliminate-rem.ll
new file mode 100644
index 000000000000..f756389398fb
--- /dev/null
+++ b/test/Transforms/IndVarSimplify/eliminate-rem.ll
@@ -0,0 +1,121 @@
+; RUN: opt -indvars -S < %s | FileCheck %s
+
+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"
+
+; Indvars should be able to eliminate this srem.
+; CHECK: @simple
+; CHECK-NOT: rem
+; CHECK: ret
+
+define void @simple(i64 %arg, double* %arg3) nounwind {
+bb:
+ %t = icmp slt i64 0, %arg ; <i1> [#uses=1]
+ br i1 %t, label %bb4, label %bb12
+
+bb4: ; preds = %bb
+ br label %bb5
+
+bb5: ; preds = %bb4, %bb5
+ %t6 = phi i64 [ %t9, %bb5 ], [ 0, %bb4 ] ; <i64> [#uses=2]
+ %t7 = srem i64 %t6, %arg ; <i64> [#uses=1]
+ %t8 = getelementptr inbounds double* %arg3, i64 %t7 ; <double*> [#uses=1]
+ store double 0.000000e+00, double* %t8
+ %t9 = add nsw i64 %t6, 1 ; <i64> [#uses=2]
+ %t10 = icmp slt i64 %t9, %arg ; <i1> [#uses=1]
+ br i1 %t10, label %bb5, label %bb11
+
+bb11: ; preds = %bb5
+ br label %bb12
+
+bb12: ; preds = %bb11, %bb
+ ret void
+}
+
+; Indvars should be able to eliminate the (i+1)%n.
+; CHECK: @f
+; CHECK-NOT: rem
+; CHECK: rem
+; CHECK-NOT: rem
+; CHECK: ret
+
+define i32 @f(i64* %arg, i64 %arg1, i64 %arg2, i64 %arg3) nounwind {
+bb:
+ %t = icmp sgt i64 %arg1, 0 ; <i1> [#uses=1]
+ br i1 %t, label %bb4, label %bb54
+
+bb4: ; preds = %bb
+ br label %bb5
+
+bb5: ; preds = %bb49, %bb4
+ %t6 = phi i64 [ %t51, %bb49 ], [ 0, %bb4 ] ; <i64> [#uses=4]
+ %t7 = phi i32 [ %t50, %bb49 ], [ 0, %bb4 ] ; <i32> [#uses=2]
+ %t8 = add nsw i64 %t6, %arg1 ; <i64> [#uses=1]
+ %t9 = add nsw i64 %t8, -2 ; <i64> [#uses=1]
+ %t10 = srem i64 %t9, %arg1 ; <i64> [#uses=1]
+ %t11 = add nsw i64 %t10, 1 ; <i64> [#uses=1]
+ %t12 = add nsw i64 %t6, 1 ; <i64> [#uses=1]
+ %t13 = srem i64 %t12, %arg1 ; <i64> [#uses=1]
+ %t14 = icmp sgt i64 %arg1, 0 ; <i1> [#uses=1]
+ br i1 %t14, label %bb15, label %bb49
+
+bb15: ; preds = %bb5
+ br label %bb16
+
+bb16: ; preds = %bb44, %bb15
+ %t17 = phi i64 [ %t46, %bb44 ], [ 0, %bb15 ] ; <i64> [#uses=1]
+ %t18 = phi i32 [ %t45, %bb44 ], [ %t7, %bb15 ] ; <i32> [#uses=2]
+ %t19 = icmp sgt i64 %arg1, 0 ; <i1> [#uses=1]
+ br i1 %t19, label %bb20, label %bb44
+
+bb20: ; preds = %bb16
+ br label %bb21
+
+bb21: ; preds = %bb21, %bb20
+ %t22 = phi i64 [ %t41, %bb21 ], [ 0, %bb20 ] ; <i64> [#uses=4]
+ %t23 = phi i32 [ %t40, %bb21 ], [ %t18, %bb20 ] ; <i32> [#uses=1]
+ %t24 = mul i64 %t6, %arg1 ; <i64> [#uses=1]
+ %t25 = mul i64 %t13, %arg1 ; <i64> [#uses=1]
+ %t26 = add nsw i64 %t24, %t22 ; <i64> [#uses=1]
+ %t27 = mul i64 %t11, %arg1 ; <i64> [#uses=1]
+ %t28 = add nsw i64 %t25, %t22 ; <i64> [#uses=1]
+ %t29 = getelementptr inbounds i64* %arg, i64 %t26 ; <i64*> [#uses=1]
+ %t30 = add nsw i64 %t27, %t22 ; <i64> [#uses=1]
+ %t31 = getelementptr inbounds i64* %arg, i64 %t28 ; <i64*> [#uses=1]
+ %t32 = zext i32 %t23 to i64 ; <i64> [#uses=1]
+ %t33 = load i64* %t29 ; <i64> [#uses=1]
+ %t34 = getelementptr inbounds i64* %arg, i64 %t30 ; <i64*> [#uses=1]
+ %t35 = load i64* %t31 ; <i64> [#uses=1]
+ %t36 = add nsw i64 %t32, %t33 ; <i64> [#uses=1]
+ %t37 = add nsw i64 %t36, %t35 ; <i64> [#uses=1]
+ %t38 = load i64* %t34 ; <i64> [#uses=1]
+ %t39 = add nsw i64 %t37, %t38 ; <i64> [#uses=1]
+ %t40 = trunc i64 %t39 to i32 ; <i32> [#uses=2]
+ %t41 = add nsw i64 %t22, 1 ; <i64> [#uses=2]
+ %t42 = icmp slt i64 %t41, %arg1 ; <i1> [#uses=1]
+ br i1 %t42, label %bb21, label %bb43
+
+bb43: ; preds = %bb21
+ br label %bb44
+
+bb44: ; preds = %bb43, %bb16
+ %t45 = phi i32 [ %t18, %bb16 ], [ %t40, %bb43 ] ; <i32> [#uses=2]
+ %t46 = add nsw i64 %t17, 1 ; <i64> [#uses=2]
+ %t47 = icmp slt i64 %t46, %arg1 ; <i1> [#uses=1]
+ br i1 %t47, label %bb16, label %bb48
+
+bb48: ; preds = %bb44
+ br label %bb49
+
+bb49: ; preds = %bb48, %bb5
+ %t50 = phi i32 [ %t7, %bb5 ], [ %t45, %bb48 ] ; <i32> [#uses=2]
+ %t51 = add nsw i64 %t6, 1 ; <i64> [#uses=2]
+ %t52 = icmp slt i64 %t51, %arg1 ; <i1> [#uses=1]
+ br i1 %t52, label %bb5, label %bb53
+
+bb53: ; preds = %bb49
+ br label %bb54
+
+bb54: ; preds = %bb53, %bb
+ %t55 = phi i32 [ 0, %bb ], [ %t50, %bb53 ] ; <i32> [#uses=1]
+ ret i32 %t55
+}
diff --git a/test/Transforms/IndVarSimplify/udiv.ll b/test/Transforms/IndVarSimplify/udiv.ll
new file mode 100644
index 000000000000..8260093d1c37
--- /dev/null
+++ b/test/Transforms/IndVarSimplify/udiv.ll
@@ -0,0 +1,162 @@
+; RUN: opt -indvars -S < %s | FileCheck %s
+
+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"
+
+@main.flags = internal global [8193 x i8] zeroinitializer, align 1 ; <[8193 x i8]*> [#uses=5]
+@.str = private constant [11 x i8] c"Count: %d\0A\00" ; <[11 x i8]*> [#uses=1]
+
+; Indvars shouldn't emit a udiv here, because there's no udiv in the
+; original code. This comes from SingleSource/Benchmarks/Shootout/sieve.c.
+
+; CHECK: @main
+; CHECK-NOT: div
+
+define i32 @main(i32 %argc, i8** nocapture %argv) nounwind {
+entry:
+ %cmp = icmp eq i32 %argc, 2 ; <i1> [#uses=1]
+ br i1 %cmp, label %cond.true, label %while.cond.preheader
+
+cond.true: ; preds = %entry
+ %arrayidx = getelementptr inbounds i8** %argv, i64 1 ; <i8**> [#uses=1]
+ %tmp2 = load i8** %arrayidx ; <i8*> [#uses=1]
+ %call = tail call i32 @atoi(i8* %tmp2) nounwind readonly ; <i32> [#uses=1]
+ br label %while.cond.preheader
+
+while.cond.preheader: ; preds = %entry, %cond.true
+ %NUM.0.ph = phi i32 [ %call, %cond.true ], [ 170000, %entry ] ; <i32> [#uses=2]
+ %tobool18 = icmp eq i32 %NUM.0.ph, 0 ; <i1> [#uses=1]
+ br i1 %tobool18, label %while.end, label %bb.nph30
+
+while.cond.loopexit: ; preds = %for.cond12.while.cond.loopexit_crit_edge, %for.cond12.loopexit
+ %count.2.lcssa = phi i32 [ %count.1.lcssa, %for.cond12.while.cond.loopexit_crit_edge ], [ 0, %for.cond12.loopexit ] ; <i32> [#uses=1]
+ br label %while.cond
+
+while.cond: ; preds = %while.cond.loopexit
+ %tobool = icmp eq i32 %dec19, 0 ; <i1> [#uses=1]
+ br i1 %tobool, label %while.cond.while.end_crit_edge, label %for.cond.preheader
+
+while.cond.while.end_crit_edge: ; preds = %while.cond
+ %count.2.lcssa.lcssa = phi i32 [ %count.2.lcssa, %while.cond ] ; <i32> [#uses=1]
+ br label %while.end
+
+bb.nph30: ; preds = %while.cond.preheader
+ br label %for.cond.preheader
+
+for.cond.preheader: ; preds = %bb.nph30, %while.cond
+ %dec19.in = phi i32 [ %NUM.0.ph, %bb.nph30 ], [ %dec19, %while.cond ] ; <i32> [#uses=1]
+ %dec19 = add i32 %dec19.in, -1 ; <i32> [#uses=2]
+ br i1 true, label %bb.nph, label %for.cond12.loopexit
+
+for.cond: ; preds = %for.body
+ %cmp8 = icmp slt i64 %inc, 8193 ; <i1> [#uses=1]
+ br i1 %cmp8, label %for.body, label %for.cond.for.cond12.loopexit_crit_edge
+
+for.cond.for.cond12.loopexit_crit_edge: ; preds = %for.cond
+ br label %for.cond12.loopexit
+
+bb.nph: ; preds = %for.cond.preheader
+ br label %for.body
+
+for.body: ; preds = %bb.nph, %for.cond
+ %i.02 = phi i64 [ 2, %bb.nph ], [ %inc, %for.cond ] ; <i64> [#uses=2]
+ %arrayidx10 = getelementptr inbounds [8193 x i8]* @main.flags, i64 0, i64 %i.02 ; <i8*> [#uses=1]
+ store i8 1, i8* %arrayidx10
+ %inc = add nsw i64 %i.02, 1 ; <i64> [#uses=2]
+ br label %for.cond
+
+for.cond12.loopexit: ; preds = %for.cond.for.cond12.loopexit_crit_edge, %for.cond.preheader
+ br i1 true, label %bb.nph16, label %while.cond.loopexit
+
+for.cond12: ; preds = %for.inc35
+ %cmp14 = icmp slt i64 %inc37, 8193 ; <i1> [#uses=1]
+ br i1 %cmp14, label %for.body15, label %for.cond12.while.cond.loopexit_crit_edge
+
+for.cond12.while.cond.loopexit_crit_edge: ; preds = %for.cond12
+ %count.1.lcssa = phi i32 [ %count.1, %for.cond12 ] ; <i32> [#uses=1]
+ br label %while.cond.loopexit
+
+bb.nph16: ; preds = %for.cond12.loopexit
+ br label %for.body15
+
+for.body15: ; preds = %bb.nph16, %for.cond12
+ %count.212 = phi i32 [ 0, %bb.nph16 ], [ %count.1, %for.cond12 ] ; <i32> [#uses=2]
+ %i.17 = phi i64 [ 2, %bb.nph16 ], [ %inc37, %for.cond12 ] ; <i64> [#uses=4]
+ %arrayidx17 = getelementptr inbounds [8193 x i8]* @main.flags, i64 0, i64 %i.17 ; <i8*> [#uses=1]
+ %tmp18 = load i8* %arrayidx17 ; <i8> [#uses=1]
+ %tobool19 = icmp eq i8 %tmp18, 0 ; <i1> [#uses=1]
+ br i1 %tobool19, label %for.inc35, label %if.then
+
+if.then: ; preds = %for.body15
+ %add = shl i64 %i.17, 1 ; <i64> [#uses=2]
+ %cmp243 = icmp slt i64 %add, 8193 ; <i1> [#uses=1]
+ br i1 %cmp243, label %bb.nph5, label %for.end32
+
+for.cond22: ; preds = %for.body25
+ %cmp24 = icmp slt i64 %add31, 8193 ; <i1> [#uses=1]
+ br i1 %cmp24, label %for.body25, label %for.cond22.for.end32_crit_edge
+
+for.cond22.for.end32_crit_edge: ; preds = %for.cond22
+ br label %for.end32
+
+bb.nph5: ; preds = %if.then
+ br label %for.body25
+
+for.body25: ; preds = %bb.nph5, %for.cond22
+ %k.04 = phi i64 [ %add, %bb.nph5 ], [ %add31, %for.cond22 ] ; <i64> [#uses=2]
+ %arrayidx27 = getelementptr inbounds [8193 x i8]* @main.flags, i64 0, i64 %k.04 ; <i8*> [#uses=1]
+ store i8 0, i8* %arrayidx27
+ %add31 = add nsw i64 %k.04, %i.17 ; <i64> [#uses=2]
+ br label %for.cond22
+
+for.end32: ; preds = %for.cond22.for.end32_crit_edge, %if.then
+ %inc34 = add nsw i32 %count.212, 1 ; <i32> [#uses=1]
+ br label %for.inc35
+
+for.inc35: ; preds = %for.body15, %for.end32
+ %count.1 = phi i32 [ %inc34, %for.end32 ], [ %count.212, %for.body15 ] ; <i32> [#uses=2]
+ %inc37 = add nsw i64 %i.17, 1 ; <i64> [#uses=2]
+ br label %for.cond12
+
+while.end: ; preds = %while.cond.while.end_crit_edge, %while.cond.preheader
+ %count.0.lcssa = phi i32 [ %count.2.lcssa.lcssa, %while.cond.while.end_crit_edge ], [ 0, %while.cond.preheader ] ; <i32> [#uses=1]
+ %call40 = tail call i32 (i8*, ...)* @printf(i8* getelementptr inbounds ([11 x i8]* @.str, i64 0, i64 0), i32 %count.0.lcssa) nounwind ; <i32> [#uses=0]
+ ret i32 0
+}
+
+declare i32 @atoi(i8* nocapture) nounwind readonly
+
+declare i32 @printf(i8* nocapture, ...) nounwind
+
+; IndVars shouldn't be afraid to emit a udiv here, since there's a udiv in
+; the original code.
+
+; CHECK: @foo
+; CHECK: for.body.preheader:
+; CHECK-NEXT: udiv
+
+define void @foo(double* %p, i64 %n) nounwind {
+entry:
+ %div0 = udiv i64 %n, 7 ; <i64> [#uses=1]
+ %div1 = add i64 %div0, 1
+ %cmp2 = icmp ult i64 0, %div1 ; <i1> [#uses=1]
+ br i1 %cmp2, label %for.body.preheader, label %for.end
+
+for.body.preheader: ; preds = %entry
+ br label %for.body
+
+for.body: ; preds = %for.body.preheader, %for.body
+ %i.03 = phi i64 [ %inc, %for.body ], [ 0, %for.body.preheader ] ; <i64> [#uses=2]
+ %arrayidx = getelementptr inbounds double* %p, i64 %i.03 ; <double*> [#uses=1]
+ store double 0.000000e+00, double* %arrayidx
+ %inc = add i64 %i.03, 1 ; <i64> [#uses=2]
+ %divx = udiv i64 %n, 7 ; <i64> [#uses=1]
+ %div = add i64 %divx, 1
+ %cmp = icmp ult i64 %inc, %div ; <i1> [#uses=1]
+ br i1 %cmp, label %for.body, label %for.end.loopexit
+
+for.end.loopexit: ; preds = %for.body
+ br label %for.end
+
+for.end: ; preds = %for.end.loopexit, %entry
+ ret void
+}