1 ; RUN: opt %loadPolly %defaultOpts -polly-codegen -enable-polly-vector -dce -S %s | FileCheck %s
2 ; Obtained from C source as:
3 ; clang -S -emit-llvm -O0 slp-reduc-4.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer slp-reduc-4.s > slp-reduc-4.ll
6 ; ModuleID = 'slp-reduc-4.s'
7 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"
8 target triple = "x86_64-unknown-linux-gnu"
10 @uc = common global [128 x i32] zeroinitializer, align 16
12 define i32 @main1(i32 %n, i32 %res0, i32 %res1, i32 %res2, i32 %res3, i32 %res4, i32 %res5, i32 %res6, i32 %res7) nounwind uwtable noinline {
14 %tmp = icmp sgt i32 %n, 0
15 %smax = select i1 %tmp, i32 %n, i32 0
18 for.cond: ; preds = %for.inc, %entry
19 %tmp24 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
20 %max0.0 = phi i32 [ 5, %entry ], [ %cond105, %for.inc ]
21 %max1.0 = phi i32 [ 10, %entry ], [ %cond50, %for.inc ]
22 %max2.0 = phi i32 [ 20, %entry ], [ %cond, %for.inc ]
23 %max3.0 = phi i32 [ 30, %entry ], [ %cond31, %for.inc ]
24 %max4.0 = phi i32 [ 2, %entry ], [ %cond124, %for.inc ]
25 %max5.0 = phi i32 [ 13, %entry ], [ %cond143, %for.inc ]
26 %max6.0 = phi i32 [ 7, %entry ], [ %cond88, %for.inc ]
27 %max7.0 = phi i32 [ 313, %entry ], [ %cond69, %for.inc ]
28 %mul91 = mul i32 %tmp24, 8
29 %add1 = add i32 %mul91, 2
30 %add162 = add i32 %mul91, 3
31 %add353 = add i32 %mul91, 1
32 %add544 = add i32 %mul91, 7
33 %add735 = add i32 %mul91, 6
34 %add1096 = add i32 %mul91, 4
35 %add1287 = add i32 %mul91, 5
36 %exitcond = icmp ne i32 %tmp24, %smax
37 br i1 %exitcond, label %for.body, label %for.end
39 for.body: ; preds = %for.cond
40 %idxprom = sext i32 %add1 to i64
41 %arrayidx = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom
42 %tmp4 = load i32* %arrayidx, align 8
43 %cmp5 = icmp ult i32 %max2.0, %tmp4
44 br i1 %cmp5, label %cond.true, label %cond.false
46 cond.true: ; preds = %for.body
47 %idxprom9 = sext i32 %add1 to i64
48 %arrayidx10 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom9
49 %tmp11 = load i32* %arrayidx10, align 8
52 cond.false: ; preds = %for.body
55 cond.end: ; preds = %cond.false, %cond.true
56 %cond = phi i32 [ %tmp11, %cond.true ], [ %max2.0, %cond.false ]
57 %idxprom17 = sext i32 %add162 to i64
58 %arrayidx18 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom17
59 %tmp19 = load i32* %arrayidx18, align 4
60 %cmp20 = icmp ult i32 %max3.0, %tmp19
61 br i1 %cmp20, label %cond.true21, label %cond.false28
63 cond.true21: ; preds = %cond.end
64 %idxprom25 = sext i32 %add162 to i64
65 %arrayidx26 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom25
66 %tmp27 = load i32* %arrayidx26, align 4
69 cond.false28: ; preds = %cond.end
72 cond.end30: ; preds = %cond.false28, %cond.true21
73 %cond31 = phi i32 [ %tmp27, %cond.true21 ], [ %max3.0, %cond.false28 ]
74 %idxprom36 = sext i32 %add353 to i64
75 %arrayidx37 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom36
76 %tmp38 = load i32* %arrayidx37, align 4
77 %cmp39 = icmp ult i32 %max1.0, %tmp38
78 br i1 %cmp39, label %cond.true40, label %cond.false47
80 cond.true40: ; preds = %cond.end30
81 %idxprom44 = sext i32 %add353 to i64
82 %arrayidx45 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom44
83 %tmp46 = load i32* %arrayidx45, align 4
86 cond.false47: ; preds = %cond.end30
89 cond.end49: ; preds = %cond.false47, %cond.true40
90 %cond50 = phi i32 [ %tmp46, %cond.true40 ], [ %max1.0, %cond.false47 ]
91 %idxprom55 = sext i32 %add544 to i64
92 %arrayidx56 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom55
93 %tmp57 = load i32* %arrayidx56, align 4
94 %cmp58 = icmp ult i32 %max7.0, %tmp57
95 br i1 %cmp58, label %cond.true59, label %cond.false66
97 cond.true59: ; preds = %cond.end49
98 %idxprom63 = sext i32 %add544 to i64
99 %arrayidx64 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom63
100 %tmp65 = load i32* %arrayidx64, align 4
103 cond.false66: ; preds = %cond.end49
106 cond.end68: ; preds = %cond.false66, %cond.true59
107 %cond69 = phi i32 [ %tmp65, %cond.true59 ], [ %max7.0, %cond.false66 ]
108 %idxprom74 = sext i32 %add735 to i64
109 %arrayidx75 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom74
110 %tmp76 = load i32* %arrayidx75, align 8
111 %cmp77 = icmp ult i32 %max6.0, %tmp76
112 br i1 %cmp77, label %cond.true78, label %cond.false85
114 cond.true78: ; preds = %cond.end68
115 %idxprom82 = sext i32 %add735 to i64
116 %arrayidx83 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom82
117 %tmp84 = load i32* %arrayidx83, align 8
120 cond.false85: ; preds = %cond.end68
123 cond.end87: ; preds = %cond.false85, %cond.true78
124 %cond88 = phi i32 [ %tmp84, %cond.true78 ], [ %max6.0, %cond.false85 ]
125 %idxprom92 = sext i32 %mul91 to i64
126 %arrayidx93 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom92
127 %tmp94 = load i32* %arrayidx93, align 16
128 %cmp95 = icmp ult i32 %max0.0, %tmp94
129 br i1 %cmp95, label %cond.true96, label %cond.false102
131 cond.true96: ; preds = %cond.end87
132 %idxprom99 = sext i32 %mul91 to i64
133 %arrayidx100 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom99
134 %tmp101 = load i32* %arrayidx100, align 16
135 br label %cond.end104
137 cond.false102: ; preds = %cond.end87
138 br label %cond.end104
140 cond.end104: ; preds = %cond.false102, %cond.true96
141 %cond105 = phi i32 [ %tmp101, %cond.true96 ], [ %max0.0, %cond.false102 ]
142 %idxprom110 = sext i32 %add1096 to i64
143 %arrayidx111 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom110
144 %tmp112 = load i32* %arrayidx111, align 16
145 %cmp113 = icmp ult i32 %max4.0, %tmp112
146 br i1 %cmp113, label %cond.true114, label %cond.false121
148 cond.true114: ; preds = %cond.end104
149 %idxprom118 = sext i32 %add1096 to i64
150 %arrayidx119 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom118
151 %tmp120 = load i32* %arrayidx119, align 16
152 br label %cond.end123
154 cond.false121: ; preds = %cond.end104
155 br label %cond.end123
157 cond.end123: ; preds = %cond.false121, %cond.true114
158 %cond124 = phi i32 [ %tmp120, %cond.true114 ], [ %max4.0, %cond.false121 ]
159 %idxprom129 = sext i32 %add1287 to i64
160 %arrayidx130 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom129
161 %tmp131 = load i32* %arrayidx130, align 4
162 %cmp132 = icmp ult i32 %max5.0, %tmp131
163 br i1 %cmp132, label %cond.true133, label %cond.false140
165 cond.true133: ; preds = %cond.end123
166 %idxprom137 = sext i32 %add1287 to i64
167 %arrayidx138 = getelementptr inbounds [128 x i32]* @uc, i64 0, i64 %idxprom137
168 %tmp139 = load i32* %arrayidx138, align 4
169 br label %cond.end142
171 cond.false140: ; preds = %cond.end123
172 br label %cond.end142
174 cond.end142: ; preds = %cond.false140, %cond.true133
175 %cond143 = phi i32 [ %tmp139, %cond.true133 ], [ %max5.0, %cond.false140 ]
178 for.inc: ; preds = %cond.end142
179 %inc = add nsw i32 %tmp24, 1
182 for.end: ; preds = %for.cond
183 %max7.0.lcssa = phi i32 [ %max7.0, %for.cond ]
184 %max6.0.lcssa = phi i32 [ %max6.0, %for.cond ]
185 %max5.0.lcssa = phi i32 [ %max5.0, %for.cond ]
186 %max4.0.lcssa = phi i32 [ %max4.0, %for.cond ]
187 %max3.0.lcssa = phi i32 [ %max3.0, %for.cond ]
188 %max2.0.lcssa = phi i32 [ %max2.0, %for.cond ]
189 %max1.0.lcssa = phi i32 [ %max1.0, %for.cond ]
190 %max0.0.lcssa = phi i32 [ %max0.0, %for.cond ]
191 %cmp147 = icmp eq i32 %max0.0.lcssa, %res0
192 br i1 %cmp147, label %lor.lhs.false, label %if.then
194 lor.lhs.false: ; preds = %for.end
195 %cmp150 = icmp eq i32 %max1.0.lcssa, %res1
196 br i1 %cmp150, label %lor.lhs.false151, label %if.then
198 lor.lhs.false151: ; preds = %lor.lhs.false
199 %cmp154 = icmp eq i32 %max2.0.lcssa, %res2
200 br i1 %cmp154, label %lor.lhs.false155, label %if.then
202 lor.lhs.false155: ; preds = %lor.lhs.false151
203 %cmp158 = icmp eq i32 %max3.0.lcssa, %res3
204 br i1 %cmp158, label %lor.lhs.false159, label %if.then
206 lor.lhs.false159: ; preds = %lor.lhs.false155
207 %cmp162 = icmp eq i32 %max4.0.lcssa, %res4
208 br i1 %cmp162, label %lor.lhs.false163, label %if.then
210 lor.lhs.false163: ; preds = %lor.lhs.false159
211 %cmp166 = icmp eq i32 %max5.0.lcssa, %res5
212 br i1 %cmp166, label %lor.lhs.false167, label %if.then
214 lor.lhs.false167: ; preds = %lor.lhs.false163
215 %cmp170 = icmp eq i32 %max6.0.lcssa, %res6
216 br i1 %cmp170, label %lor.lhs.false171, label %if.then
218 lor.lhs.false171: ; preds = %lor.lhs.false167
219 %cmp174 = icmp eq i32 %max7.0.lcssa, %res7
220 br i1 %cmp174, label %if.end, label %if.then
222 if.then: ; preds = %lor.lhs.false171, %lor.lhs.false167, %lor.lhs.false163, %lor.lhs.false159, %lor.lhs.false155, %lor.lhs.false151, %lor.lhs.false, %for.end
223 call void @abort() noreturn nounwind
226 if.end: ; preds = %lor.lhs.false171
230 declare void @abort() noreturn
232 define i32 @main() nounwind uwtable {
234 call void @check_vect()
237 for.cond: ; preds = %for.inc, %entry
238 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
239 %arrayidx = getelementptr [128 x i32]* @uc, i64 0, i64 %indvar
240 %tmp = add i64 %indvar, 3
241 %add = trunc i64 %tmp to i32
242 %exitcond = icmp ne i64 %indvar, 128
243 br i1 %exitcond, label %for.body, label %for.end
245 for.body: ; preds = %for.cond
246 store i32 %add, i32* %arrayidx, align 4
247 call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"() nounwind, !srcloc !0
250 for.inc: ; preds = %for.body
251 %indvar.next = add i64 %indvar, 1
254 for.end: ; preds = %for.cond
255 %call = call i32 @main1(i32 16, i32 123, i32 124, i32 125, i32 126, i32 127, i32 128, i32 129, i32 313)
259 define internal void @check_vect() nounwind uwtable noinline {
261 %a = alloca i32, align 4
262 %b = alloca i32, align 4
263 %c = alloca i32, align 4
264 %d = alloca i32, align 4
265 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
266 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
267 %tobool = icmp eq i32 %call1, 0
268 br i1 %tobool, label %if.then, label %lor.lhs.false
270 lor.lhs.false: ; preds = %entry
271 %tmp4 = load i32* %d, align 4
272 %and6 = and i32 %tmp4, 67108864
273 %cmp = icmp eq i32 %and6, 0
274 br i1 %cmp, label %if.then, label %if.end
276 if.then: ; preds = %entry, %lor.lhs.false
277 call void @exit(i32 0) noreturn nounwind
280 if.end: ; preds = %lor.lhs.false
281 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
285 declare void (i32)* @signal(i32, void (i32)*) nounwind
287 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
289 call void @exit(i32 0) noreturn nounwind
292 return: ; No predecessors!
296 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
298 %and = and i32 %__level, -2147483648
299 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
300 %cmp = icmp ult i32 %call, %__level
301 br i1 %cmp, label %if.then, label %if.end
303 if.then: ; preds = %entry
306 if.end: ; preds = %entry
307 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !1
308 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
309 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
310 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
311 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
312 store i32 %asmresult, i32* %__eax, align 4
313 store i32 %asmresult8, i32* %__ebx, align 4
314 store i32 %asmresult9, i32* %__ecx, align 4
315 store i32 %asmresult10, i32* %__edx, align 4
318 return: ; preds = %if.end, %if.then
319 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
323 declare void @exit(i32) noreturn
325 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
327 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !2
328 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
329 %tobool = icmp eq i32* %__sig, null
330 br i1 %tobool, label %if.end, label %if.then
332 if.then: ; preds = %entry
333 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
334 store i32 %asmresult1, i32* %__sig, align 4
337 if.end: ; preds = %entry, %if.then
341 !0 = metadata !{i32 1188}
342 !1 = metadata !{i32 -2147342796, i32 -2147342788}
343 !2 = metadata !{i32 -2147342919, i32 -2147342911}