• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1; RUN: opt < %s -indvars -S | FileCheck %s
2
3; Provide legal integer types.
4target datalayout = "n8:16:32:64"
5
6
7@a = common global i32 0, align 4
8@c = common global i32 0, align 4
9@b = common global i32 0, align 4
10
11define void @f() {
12; CHECK-LABEL: @f(
13; CHECK-LABEL: entry:
14; CHECK: br label %[[for_cond2_preheader:.*]]
15
16; CHECK: [[for_cond2_preheader]]:
17; CHECK-NEXT: %[[indvars_iv:.*]] = phi i32 [ %[[indvars_iv_next:.*]], %[[for_inc13:.*]] ], [ -14, %entry ]
18; br i1 {{.*}}, label %[[for_inc13]], label %
19entry:
20  %0 = load i32, i32* @a, align 4
21  %tobool2 = icmp eq i32 %0, 0
22  %1 = load i32, i32* @a, align 4
23  %tobool = icmp eq i32 %1, 0
24  br label %for.cond2.preheader
25
26for.cond2.preheader:                              ; preds = %for.inc13, %entry
27  %storemerge15 = phi i8 [ -14, %entry ], [ %inc14, %for.inc13 ]
28  br i1 %tobool2, label %for.inc13, label %for.body3.lr.ph
29
30for.body3.lr.ph:                                  ; preds = %for.cond2.preheader
31  %tobool5 = icmp eq i8 %storemerge15, 0
32  %conv7 = sext i8 %storemerge15 to i32
33  %2 = add nsw i32 %conv7, 1
34  %3 = icmp ult i32 %2, 3
35  %div = select i1 %3, i32 %conv7, i32 0
36  br i1 %tobool5, label %for.body3.lr.ph.split.us, label %for.body3.lr.ph.for.body3.lr.ph.split_crit_edge
37
38for.body3.lr.ph.for.body3.lr.ph.split_crit_edge:  ; preds = %for.body3.lr.ph
39  br label %for.body3.lr.ph.split
40
41for.body3.lr.ph.split.us:                         ; preds = %for.body3.lr.ph
42  br i1 %tobool, label %for.body3.lr.ph.split.us.split.us, label %for.body3.lr.ph.split.us.for.body3.lr.ph.split.us.split_crit_edge
43
44for.body3.lr.ph.split.us.for.body3.lr.ph.split.us.split_crit_edge: ; preds = %for.body3.lr.ph.split.us
45  br label %for.body3.lr.ph.split.us.split
46
47for.body3.lr.ph.split.us.split.us:                ; preds = %for.body3.lr.ph.split.us
48  br label %for.body3.us.us
49
50for.body3.us.us:                                  ; preds = %for.cond2.loopexit.us.us, %for.body3.lr.ph.split.us.split.us
51  br i1 true, label %cond.false.us.us, label %cond.end.us.us
52
53cond.false.us.us:                                 ; preds = %for.body3.us.us
54  br label %cond.end.us.us
55
56cond.end.us.us:                                   ; preds = %cond.false.us.us, %for.body3.us.us
57  %cond.us.us = phi i32 [ %div, %cond.false.us.us ], [ %conv7, %for.body3.us.us ]
58  %4 = load i32, i32* @b, align 4
59  %cmp91.us.us = icmp slt i32 %4, 1
60  br i1 %cmp91.us.us, label %for.inc.lr.ph.us.us, label %for.cond2.loopexit.us.us
61
62for.cond2.loopexit.us.us:                         ; preds = %for.cond8.for.cond2.loopexit_crit_edge.us.us, %cond.end.us.us
63  br i1 true, label %for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa.us, label %for.body3.us.us
64
65for.inc.lr.ph.us.us:                              ; preds = %cond.end.us.us
66  br label %for.inc.us.us
67
68for.cond8.for.cond2.loopexit_crit_edge.us.us:     ; preds = %for.inc.us.us
69  %inc.lcssa.us.us = phi i32 [ %inc.us.us, %for.inc.us.us ]
70  store i32 %inc.lcssa.us.us, i32* @b, align 4
71  br label %for.cond2.loopexit.us.us
72
73for.inc.us.us:                                    ; preds = %for.inc.us.us, %for.inc.lr.ph.us.us
74  %5 = phi i32 [ %4, %for.inc.lr.ph.us.us ], [ %inc.us.us, %for.inc.us.us ]
75  %inc.us.us = add nsw i32 %5, 1
76  %cmp9.us.us = icmp slt i32 %inc.us.us, 1
77  br i1 %cmp9.us.us, label %for.inc.us.us, label %for.cond8.for.cond2.loopexit_crit_edge.us.us
78
79for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa.us: ; preds = %for.cond2.loopexit.us.us
80  %cond.lcssa.ph.us.ph.us = phi i32 [ %cond.us.us, %for.cond2.loopexit.us.us ]
81  br label %for.cond2.for.inc13_crit_edge.us-lcssa.us
82
83for.body3.lr.ph.split.us.split:                   ; preds = %for.body3.lr.ph.split.us.for.body3.lr.ph.split.us.split_crit_edge
84  br label %for.body3.us
85
86for.body3.us:                                     ; preds = %for.cond2.loopexit.us, %for.body3.lr.ph.split.us.split
87  br i1 true, label %cond.false.us, label %cond.end.us
88
89cond.false.us:                                    ; preds = %for.body3.us
90  br label %cond.end.us
91
92cond.end.us:                                      ; preds = %cond.false.us, %for.body3.us
93  %cond.us = phi i32 [ %div, %cond.false.us ], [ %conv7, %for.body3.us ]
94  %6 = load i32, i32* @b, align 4
95  %cmp91.us = icmp slt i32 %6, 1
96  br i1 %cmp91.us, label %for.inc.lr.ph.us, label %for.cond2.loopexit.us
97
98for.inc.us:                                       ; preds = %for.inc.lr.ph.us, %for.inc.us
99  %7 = phi i32 [ %6, %for.inc.lr.ph.us ], [ %inc.us, %for.inc.us ]
100  %inc.us = add nsw i32 %7, 1
101  %cmp9.us = icmp slt i32 %inc.us, 1
102  br i1 %cmp9.us, label %for.inc.us, label %for.cond8.for.cond2.loopexit_crit_edge.us
103
104for.cond2.loopexit.us:                            ; preds = %for.cond8.for.cond2.loopexit_crit_edge.us, %cond.end.us
105  br i1 false, label %for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa, label %for.body3.us
106
107for.inc.lr.ph.us:                                 ; preds = %cond.end.us
108  br label %for.inc.us
109
110for.cond8.for.cond2.loopexit_crit_edge.us:        ; preds = %for.inc.us
111  %inc.lcssa.us = phi i32 [ %inc.us, %for.inc.us ]
112  store i32 %inc.lcssa.us, i32* @b, align 4
113  br label %for.cond2.loopexit.us
114
115for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa: ; preds = %for.cond2.loopexit.us
116  %cond.lcssa.ph.us.ph = phi i32 [ %cond.us, %for.cond2.loopexit.us ]
117  br label %for.cond2.for.inc13_crit_edge.us-lcssa.us
118
119for.cond2.for.inc13_crit_edge.us-lcssa.us:        ; preds = %for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa, %for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa.us
120  %cond.lcssa.ph.us = phi i32 [ %cond.lcssa.ph.us.ph, %for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa ], [ %cond.lcssa.ph.us.ph.us, %for.cond2.for.inc13_crit_edge.us-lcssa.us.us-lcssa.us ]
121  br label %for.cond2.for.inc13_crit_edge
122
123for.body3.lr.ph.split:                            ; preds = %for.body3.lr.ph.for.body3.lr.ph.split_crit_edge
124  br i1 %tobool, label %for.body3.lr.ph.split.split.us, label %for.body3.lr.ph.split.for.body3.lr.ph.split.split_crit_edge
125
126for.body3.lr.ph.split.for.body3.lr.ph.split.split_crit_edge: ; preds = %for.body3.lr.ph.split
127  br label %for.body3.lr.ph.split.split
128
129for.body3.lr.ph.split.split.us:                   ; preds = %for.body3.lr.ph.split
130  br label %for.body3.us3
131
132for.body3.us3:                                    ; preds = %for.cond2.loopexit.us11, %for.body3.lr.ph.split.split.us
133  br i1 false, label %cond.false.us4, label %cond.end.us5
134
135cond.false.us4:                                   ; preds = %for.body3.us3
136  br label %cond.end.us5
137
138cond.end.us5:                                     ; preds = %cond.false.us4, %for.body3.us3
139  %cond.us6 = phi i32 [ %div, %cond.false.us4 ], [ %conv7, %for.body3.us3 ]
140  %8 = load i32, i32* @b, align 4
141  %cmp91.us7 = icmp slt i32 %8, 1
142  br i1 %cmp91.us7, label %for.inc.lr.ph.us12, label %for.cond2.loopexit.us11
143
144for.inc.us8:                                      ; preds = %for.inc.lr.ph.us12, %for.inc.us8
145  %9 = phi i32 [ %8, %for.inc.lr.ph.us12 ], [ %inc.us9, %for.inc.us8 ]
146  %inc.us9 = add nsw i32 %9, 1
147  %cmp9.us10 = icmp slt i32 %inc.us9, 1
148  br i1 %cmp9.us10, label %for.inc.us8, label %for.cond8.for.cond2.loopexit_crit_edge.us13
149
150for.cond2.loopexit.us11:                          ; preds = %for.cond8.for.cond2.loopexit_crit_edge.us13, %cond.end.us5
151  br i1 true, label %for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa.us, label %for.body3.us3
152
153for.inc.lr.ph.us12:                               ; preds = %cond.end.us5
154  br label %for.inc.us8
155
156for.cond8.for.cond2.loopexit_crit_edge.us13:      ; preds = %for.inc.us8
157  %inc.lcssa.us14 = phi i32 [ %inc.us9, %for.inc.us8 ]
158  store i32 %inc.lcssa.us14, i32* @b, align 4
159  br label %for.cond2.loopexit.us11
160
161for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa.us: ; preds = %for.cond2.loopexit.us11
162  %cond.lcssa.ph.ph.us = phi i32 [ %cond.us6, %for.cond2.loopexit.us11 ]
163  br label %for.cond2.for.inc13_crit_edge.us-lcssa
164
165for.body3.lr.ph.split.split:                      ; preds = %for.body3.lr.ph.split.for.body3.lr.ph.split.split_crit_edge
166  br label %for.body3
167
168for.cond8.for.cond2.loopexit_crit_edge:           ; preds = %for.inc
169  %inc.lcssa = phi i32 [ %inc, %for.inc ]
170  store i32 %inc.lcssa, i32* @b, align 4
171  br label %for.cond2.loopexit
172
173for.cond2.loopexit:                               ; preds = %cond.end, %for.cond8.for.cond2.loopexit_crit_edge
174  br i1 false, label %for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa, label %for.body3
175
176for.body3:                                        ; preds = %for.cond2.loopexit, %for.body3.lr.ph.split.split
177  br i1 false, label %cond.false, label %cond.end
178
179cond.false:                                       ; preds = %for.body3
180  br label %cond.end
181
182cond.end:                                         ; preds = %cond.false, %for.body3
183  %cond = phi i32 [ %div, %cond.false ], [ %conv7, %for.body3 ]
184  %10 = load i32, i32* @b, align 4
185  %cmp91 = icmp slt i32 %10, 1
186  br i1 %cmp91, label %for.inc.lr.ph, label %for.cond2.loopexit
187
188for.inc.lr.ph:                                    ; preds = %cond.end
189  br label %for.inc
190
191for.inc:                                          ; preds = %for.inc, %for.inc.lr.ph
192  %11 = phi i32 [ %10, %for.inc.lr.ph ], [ %inc, %for.inc ]
193  %inc = add nsw i32 %11, 1
194  %cmp9 = icmp slt i32 %inc, 1
195  br i1 %cmp9, label %for.inc, label %for.cond8.for.cond2.loopexit_crit_edge
196
197for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa:  ; preds = %for.cond2.loopexit
198  %cond.lcssa.ph.ph = phi i32 [ %cond, %for.cond2.loopexit ]
199  br label %for.cond2.for.inc13_crit_edge.us-lcssa
200
201for.cond2.for.inc13_crit_edge.us-lcssa:           ; preds = %for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa, %for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa.us
202  %cond.lcssa.ph = phi i32 [ %cond.lcssa.ph.ph, %for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa ], [ %cond.lcssa.ph.ph.us, %for.cond2.for.inc13_crit_edge.us-lcssa.us-lcssa.us ]
203  br label %for.cond2.for.inc13_crit_edge
204
205for.cond2.for.inc13_crit_edge:                    ; preds = %for.cond2.for.inc13_crit_edge.us-lcssa, %for.cond2.for.inc13_crit_edge.us-lcssa.us
206  %cond.lcssa = phi i32 [ %cond.lcssa.ph, %for.cond2.for.inc13_crit_edge.us-lcssa ], [ %cond.lcssa.ph.us, %for.cond2.for.inc13_crit_edge.us-lcssa.us ]
207  store i32 %cond.lcssa, i32* @c, align 4
208  br label %for.inc13
209
210; CHECK: [[for_inc13]]:
211; CHECK-NEXT: %[[indvars_iv_next]] = add nsw i32 %[[indvars_iv]], 1
212; CHECK-NEXT: %[[exitcond4:.*]] = icmp ne i32 %[[indvars_iv_next]], 0
213; CHECK-NEXT: br i1 %[[exitcond4]], label %[[for_cond2_preheader]], label %[[for_end15:.*]]
214for.inc13:                                        ; preds = %for.cond2.for.inc13_crit_edge, %for.cond2.preheader
215  %inc14 = add i8 %storemerge15, 1
216  %cmp = icmp ugt i8 %inc14, 50
217  br i1 %cmp, label %for.cond2.preheader, label %for.end15
218
219; CHECK: [[for_end15]]:
220; CHECK-NEXT: ret void
221for.end15:                                        ; preds = %for.inc13
222  ret void
223}
224