1 ; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s
2 ; CHECK: define void @foo
8 ; CHECK: define void @bar
15 define void @foo(i64 %n, i64 %m, i64 %o, double* nocapture %p) nounwind {
17 %tmp = icmp sgt i64 %n, 0 ; <i1> [#uses=1]
18 br i1 %tmp, label %bb.nph, label %return
20 bb.nph: ; preds = %entry
21 %tmp1 = mul i64 %n, 37 ; <i64> [#uses=1]
22 %tmp2 = mul i64 %tmp1, %m ; <i64> [#uses=1]
23 %tmp3 = mul i64 %tmp2, %o ; <i64> [#uses=1]
26 bb: ; preds = %bb, %bb.nph
27 %i.01 = phi i64 [ %tmp3, %bb.nph ], [ %tmp13, %bb ] ; <i64> [#uses=3]
28 %tmp9 = getelementptr double* %p, i64 %i.01 ; <double*> [#uses=1]
29 %tmp10 = load double* %tmp9, align 8 ; <double> [#uses=1]
30 %tmp11 = fdiv double %tmp10, 2.100000e+00 ; <double> [#uses=1]
31 store double %tmp11, double* %tmp9, align 8
32 %tmp13 = add i64 %i.01, 1 ; <i64> [#uses=2]
33 %tmp14 = icmp slt i64 %tmp13, %n ; <i1> [#uses=1]
34 br i1 %tmp14, label %bb, label %return.loopexit
36 return.loopexit: ; preds = %bb
39 return: ; preds = %return.loopexit, %entry
42 define void @bar(i64 %n, i64 %m, i64 %o, i64 %q, double* nocapture %p) nounwind {
44 %tmp = icmp sgt i64 %n, 0 ; <i1> [#uses=1]
45 br i1 %tmp, label %bb.nph, label %return
47 bb.nph: ; preds = %entry
48 %tmp1 = mul i64 %n, %q ; <i64> [#uses=1]
49 %tmp2 = mul i64 %tmp1, %m ; <i64> [#uses=1]
50 %tmp3 = mul i64 %tmp2, %o ; <i64> [#uses=1]
53 bb: ; preds = %bb, %bb.nph
54 %i.01 = phi i64 [ %tmp3, %bb.nph ], [ %tmp13, %bb ] ; <i64> [#uses=3]
55 %tmp9 = getelementptr double* %p, i64 %i.01 ; <double*> [#uses=1]
56 %tmp10 = load double* %tmp9, align 8 ; <double> [#uses=1]
57 %tmp11 = fdiv double %tmp10, 2.100000e+00 ; <double> [#uses=1]
58 store double %tmp11, double* %tmp9, align 8
59 %tmp13 = add i64 %i.01, 1 ; <i64> [#uses=2]
60 %tmp14 = icmp slt i64 %tmp13, %n ; <i1> [#uses=1]
61 br i1 %tmp14, label %bb, label %return.loopexit
63 return.loopexit: ; preds = %bb
66 return: ; preds = %return.loopexit, %entry