7e1e2a31768c6b69653fb400eb3558165efd6f81
[oota-llvm.git] / test / Transforms / IndVarSimplify / gep-with-mul-base.ll
1 ; RUN: opt < %s -indvars -S -enable-iv-rewrite | FileCheck %s
2 ; CHECK: define void @foo
3 ; CHECK: mul
4 ; CHECK: mul
5 ; CHECK: mul
6 ; CHECK: add
7 ; CHECK: sub
8 ; CHECK: define void @bar
9 ; CHECK: mul
10 ; CHECK: mul
11 ; CHECK: mul
12 ; CHECK: add
13 ; CHECK: sub
14
15 define void @foo(i64 %n, i64 %m, i64 %o, double* nocapture %p) nounwind {
16 entry:
17         %tmp = icmp sgt i64 %n, 0               ; <i1> [#uses=1]
18         br i1 %tmp, label %bb.nph, label %return
19
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]
24         br label %bb
25
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
35
36 return.loopexit:                ; preds = %bb
37         br label %return
38
39 return:         ; preds = %return.loopexit, %entry
40         ret void
41 }
42 define void @bar(i64 %n, i64 %m, i64 %o, i64 %q, double* nocapture %p) nounwind {
43 entry:
44         %tmp = icmp sgt i64 %n, 0               ; <i1> [#uses=1]
45         br i1 %tmp, label %bb.nph, label %return
46
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]
51         br label %bb
52
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
62
63 return.loopexit:                ; preds = %bb
64         br label %return
65
66 return:         ; preds = %return.loopexit, %entry
67         ret void
68 }