Revert r75252 which was causing some crashes at compile time.
[oota-llvm.git] / test / Transforms / IndVarSimplify / iv-sext.ll
1 ; RUN: llvm-as < %s | opt -indvars | llvm-dis > %t
2 ; RUN: grep {= sext} %t | count 4
3 ; RUN: grep {phi i64} %t | count 2
4 ; XFAIL: *
5
6 ; Indvars should be able to promote the hiPart induction variable in the
7 ; inner loop to i64.
8 ; TODO: it should promote hiPart to i64 in the outer loop too.
9
10 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"
11
12 define void @t(float* %pTmp1, float* %peakWeight, float* %nrgReducePeakrate, i32 %bandEdgeIndex, float %tmp1) nounwind {
13 entry:
14         %tmp = load float* %peakWeight, align 4         ; <float> [#uses=1]
15         %tmp2 = icmp sgt i32 %bandEdgeIndex, 0          ; <i1> [#uses=1]
16         br i1 %tmp2, label %bb.nph22, label %return
17
18 bb.nph22:               ; preds = %entry
19         %tmp3 = add i32 %bandEdgeIndex, -1              ; <i32> [#uses=2]
20         br label %bb
21
22 bb:             ; preds = %bb8, %bb.nph22
23         %distERBhi.121 = phi float [ %distERBhi.2.lcssa, %bb8 ], [ 0.000000e+00, %bb.nph22 ]            ; <float> [#uses=2]
24         %distERBlo.120 = phi float [ %distERBlo.0.lcssa, %bb8 ], [ 0.000000e+00, %bb.nph22 ]            ; <float> [#uses=2]
25         %hiPart.119 = phi i32 [ %hiPart.0.lcssa, %bb8 ], [ 0, %bb.nph22 ]               ; <i32> [#uses=3]
26         %loPart.118 = phi i32 [ %loPart.0.lcssa, %bb8 ], [ 0, %bb.nph22 ]               ; <i32> [#uses=2]
27         %peakCount.117 = phi float [ %peakCount.2.lcssa, %bb8 ], [ %tmp, %bb.nph22 ]            ; <float> [#uses=2]
28         %part.016 = phi i32 [ %tmp46, %bb8 ], [ 0, %bb.nph22 ]          ; <i32> [#uses=5]
29         %tmp4 = icmp sgt i32 %part.016, 0               ; <i1> [#uses=1]
30         br i1 %tmp4, label %bb1, label %bb3.preheader
31
32 bb1:            ; preds = %bb
33         %tmp5 = add i32 %part.016, -1           ; <i32> [#uses=1]
34         %tmp6 = sext i32 %tmp5 to i64           ; <i64> [#uses=1]
35         %tmp7 = getelementptr float* %pTmp1, i64 %tmp6          ; <float*> [#uses=1]
36         %tmp8 = load float* %tmp7, align 4              ; <float> [#uses=1]
37         %tmp9 = fadd float %tmp8, %distERBlo.120                ; <float> [#uses=1]
38         %tmp10 = add i32 %part.016, -1          ; <i32> [#uses=1]
39         %tmp11 = sext i32 %tmp10 to i64         ; <i64> [#uses=1]
40         %tmp12 = getelementptr float* %pTmp1, i64 %tmp11                ; <float*> [#uses=1]
41         %tmp13 = load float* %tmp12, align 4            ; <float> [#uses=1]
42         %tmp14 = fsub float %distERBhi.121, %tmp13              ; <float> [#uses=1]
43         br label %bb3.preheader
44
45 bb3.preheader:          ; preds = %bb1, %bb
46         %distERBlo.0.ph = phi float [ %distERBlo.120, %bb ], [ %tmp9, %bb1 ]            ; <float> [#uses=3]
47         %distERBhi.0.ph = phi float [ %distERBhi.121, %bb ], [ %tmp14, %bb1 ]           ; <float> [#uses=3]
48         %tmp15 = fcmp ogt float %distERBlo.0.ph, 2.500000e+00           ; <i1> [#uses=1]
49         br i1 %tmp15, label %bb.nph, label %bb5.preheader
50
51 bb.nph:         ; preds = %bb3.preheader
52         br label %bb2
53
54 bb2:            ; preds = %bb3, %bb.nph
55         %distERBlo.03 = phi float [ %tmp19, %bb3 ], [ %distERBlo.0.ph, %bb.nph ]                ; <float> [#uses=1]
56         %loPart.02 = phi i32 [ %tmp24, %bb3 ], [ %loPart.118, %bb.nph ]         ; <i32> [#uses=3]
57         %peakCount.01 = phi float [ %tmp23, %bb3 ], [ %peakCount.117, %bb.nph ]         ; <float> [#uses=1]
58         %tmp16 = sext i32 %loPart.02 to i64             ; <i64> [#uses=1]
59         %tmp17 = getelementptr float* %pTmp1, i64 %tmp16                ; <float*> [#uses=1]
60         %tmp18 = load float* %tmp17, align 4            ; <float> [#uses=1]
61         %tmp19 = fsub float %distERBlo.03, %tmp18               ; <float> [#uses=3]
62         %tmp20 = sext i32 %loPart.02 to i64             ; <i64> [#uses=1]
63         %tmp21 = getelementptr float* %peakWeight, i64 %tmp20           ; <float*> [#uses=1]
64         %tmp22 = load float* %tmp21, align 4            ; <float> [#uses=1]
65         %tmp23 = fsub float %peakCount.01, %tmp22               ; <float> [#uses=2]
66         %tmp24 = add i32 %loPart.02, 1          ; <i32> [#uses=2]
67         br label %bb3
68
69 bb3:            ; preds = %bb2
70         %tmp25 = fcmp ogt float %tmp19, 2.500000e+00            ; <i1> [#uses=1]
71         br i1 %tmp25, label %bb2, label %bb3.bb5.preheader_crit_edge
72
73 bb3.bb5.preheader_crit_edge:            ; preds = %bb3
74         %tmp24.lcssa = phi i32 [ %tmp24, %bb3 ]         ; <i32> [#uses=1]
75         %tmp23.lcssa = phi float [ %tmp23, %bb3 ]               ; <float> [#uses=1]
76         %tmp19.lcssa = phi float [ %tmp19, %bb3 ]               ; <float> [#uses=1]
77         br label %bb5.preheader
78
79 bb5.preheader:          ; preds = %bb3.bb5.preheader_crit_edge, %bb3.preheader
80         %distERBlo.0.lcssa = phi float [ %tmp19.lcssa, %bb3.bb5.preheader_crit_edge ], [ %distERBlo.0.ph, %bb3.preheader ]              ; <float> [#uses=2]
81         %loPart.0.lcssa = phi i32 [ %tmp24.lcssa, %bb3.bb5.preheader_crit_edge ], [ %loPart.118, %bb3.preheader ]               ; <i32> [#uses=1]
82         %peakCount.0.lcssa = phi float [ %tmp23.lcssa, %bb3.bb5.preheader_crit_edge ], [ %peakCount.117, %bb3.preheader ]               ; <float> [#uses=2]
83         %.not10 = fcmp olt float %distERBhi.0.ph, 2.500000e+00          ; <i1> [#uses=1]
84         %tmp26 = icmp sgt i32 %tmp3, %hiPart.119                ; <i1> [#uses=1]
85         %or.cond11 = and i1 %tmp26, %.not10             ; <i1> [#uses=1]
86         br i1 %or.cond11, label %bb.nph12, label %bb7
87
88 bb.nph12:               ; preds = %bb5.preheader
89         br label %bb4
90
91 bb4:            ; preds = %bb5, %bb.nph12
92         %distERBhi.29 = phi float [ %tmp30, %bb5 ], [ %distERBhi.0.ph, %bb.nph12 ]              ; <float> [#uses=1]
93         %hiPart.08 = phi i32 [ %tmp31, %bb5 ], [ %hiPart.119, %bb.nph12 ]               ; <i32> [#uses=2]
94         %peakCount.27 = phi float [ %tmp35, %bb5 ], [ %peakCount.0.lcssa, %bb.nph12 ]           ; <float> [#uses=1]
95         %tmp27 = sext i32 %hiPart.08 to i64             ; <i64> [#uses=1]
96         %tmp28 = getelementptr float* %pTmp1, i64 %tmp27                ; <float*> [#uses=1]
97         %tmp29 = load float* %tmp28, align 4            ; <float> [#uses=1]
98         %tmp30 = fadd float %tmp29, %distERBhi.29               ; <float> [#uses=3]
99         %tmp31 = add i32 %hiPart.08, 1          ; <i32> [#uses=4]
100         %tmp32 = sext i32 %tmp31 to i64         ; <i64> [#uses=1]
101         %tmp33 = getelementptr float* %peakWeight, i64 %tmp32           ; <float*> [#uses=1]
102         %tmp34 = load float* %tmp33, align 4            ; <float> [#uses=1]
103         %tmp35 = fadd float %tmp34, %peakCount.27               ; <float> [#uses=2]
104         br label %bb5
105
106 bb5:            ; preds = %bb4
107         %.not = fcmp olt float %tmp30, 2.500000e+00             ; <i1> [#uses=1]
108         %tmp36 = icmp sgt i32 %tmp3, %tmp31             ; <i1> [#uses=1]
109         %or.cond = and i1 %tmp36, %.not         ; <i1> [#uses=1]
110         br i1 %or.cond, label %bb4, label %bb5.bb7_crit_edge
111
112 bb5.bb7_crit_edge:              ; preds = %bb5
113         %tmp35.lcssa = phi float [ %tmp35, %bb5 ]               ; <float> [#uses=1]
114         %tmp31.lcssa = phi i32 [ %tmp31, %bb5 ]         ; <i32> [#uses=1]
115         %tmp30.lcssa = phi float [ %tmp30, %bb5 ]               ; <float> [#uses=1]
116         br label %bb7
117
118 bb7:            ; preds = %bb5.bb7_crit_edge, %bb5.preheader
119         %distERBhi.2.lcssa = phi float [ %tmp30.lcssa, %bb5.bb7_crit_edge ], [ %distERBhi.0.ph, %bb5.preheader ]                ; <float> [#uses=2]
120         %hiPart.0.lcssa = phi i32 [ %tmp31.lcssa, %bb5.bb7_crit_edge ], [ %hiPart.119, %bb5.preheader ]         ; <i32> [#uses=1]
121         %peakCount.2.lcssa = phi float [ %tmp35.lcssa, %bb5.bb7_crit_edge ], [ %peakCount.0.lcssa, %bb5.preheader ]             ; <float> [#uses=2]
122         %tmp37 = fadd float %distERBlo.0.lcssa, %distERBhi.2.lcssa              ; <float> [#uses=1]
123         %tmp38 = fdiv float %peakCount.2.lcssa, %tmp37          ; <float> [#uses=1]
124         %tmp39 = fmul float %tmp38, %tmp1               ; <float> [#uses=2]
125         %tmp40 = fmul float %tmp39, %tmp39              ; <float> [#uses=2]
126         %tmp41 = fmul float %tmp40, %tmp40              ; <float> [#uses=1]
127         %tmp42 = fadd float %tmp41, 1.000000e+00                ; <float> [#uses=1]
128         %tmp43 = fdiv float 1.000000e+00, %tmp42                ; <float> [#uses=1]
129         %tmp44 = sext i32 %part.016 to i64              ; <i64> [#uses=1]
130         %tmp45 = getelementptr float* %nrgReducePeakrate, i64 %tmp44            ; <float*> [#uses=1]
131         store float %tmp43, float* %tmp45, align 4
132         %tmp46 = add i32 %part.016, 1           ; <i32> [#uses=2]
133         br label %bb8
134
135 bb8:            ; preds = %bb7
136         %tmp47 = icmp slt i32 %tmp46, %bandEdgeIndex            ; <i1> [#uses=1]
137         br i1 %tmp47, label %bb, label %bb8.return_crit_edge
138
139 bb8.return_crit_edge:           ; preds = %bb8
140         br label %return
141
142 return:         ; preds = %bb8.return_crit_edge, %entry
143         ret void
144 }