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 vect-double-reduc-1.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-double-reduc-1.s > vect-double-reduc-1.ll
6 ; ModuleID = 'vect-double-reduc-1.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 @check_result = global [32 x i32] [i32 642816, i32 660736, i32 678656, i32 696576, i32 714496, i32 732416, i32 750336, i32 768256, i32 786176, i32 804096, i32 822016, i32 839936, i32 857856, i32 875776, i32 893696, i32 911616, i32 929536, i32 947456, i32 965376, i32 983296, i32 1001216, i32 1019136, i32 1037056, i32 1054976, i32 1072896, i32 1090816, i32 1108736, i32 1126656, i32 1144576, i32 1162496, i32 1180416, i32 1198336], align 16
11 @in = common global [64 x [32 x i32]] zeroinitializer, align 16
12 @coeff = common global [32 x [32 x i32]] zeroinitializer, align 16
13 @out = common global [32 x i32] zeroinitializer, align 16
15 define void @foo() nounwind uwtable noinline {
19 for.cond: ; preds = %for.inc33, %entry
20 %indvar3 = phi i64 [ %indvar.next4, %for.inc33 ], [ 0, %entry ]
21 %arrayidx32 = getelementptr [32 x i32]* @out, i64 0, i64 %indvar3
22 %exitcond9 = icmp ne i64 %indvar3, 32
23 br i1 %exitcond9, label %for.body, label %for.end36
25 for.body: ; preds = %for.cond
28 for.cond1: ; preds = %for.inc25, %for.body
29 %indvar1 = phi i64 [ %indvar.next2, %for.inc25 ], [ 0, %for.body ]
30 %sum.0 = phi i32 [ 0, %for.body ], [ %sum.1.lcssa, %for.inc25 ]
31 %exitcond6 = icmp ne i64 %indvar1, 32
32 br i1 %exitcond6, label %for.body4, label %for.end28
34 for.body4: ; preds = %for.cond1
37 for.cond5: ; preds = %for.inc, %for.body4
38 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %for.body4 ]
39 %sum.1 = phi i32 [ %sum.0, %for.body4 ], [ %add23, %for.inc ]
40 %tmp = add i64 %indvar3, %indvar
41 %arrayidx13 = getelementptr [64 x [32 x i32]]* @in, i64 0, i64 %tmp, i64 %indvar1
42 %arrayidx20 = getelementptr [32 x [32 x i32]]* @coeff, i64 0, i64 %indvar, i64 %indvar1
43 %exitcond = icmp ne i64 %indvar, 32
44 br i1 %exitcond, label %for.body8, label %for.end
46 for.body8: ; preds = %for.cond5
49 for.inc: ; preds = %for.body8
50 %tmp21 = load i32* %arrayidx20, align 4
51 %tmp14 = load i32* %arrayidx13, align 4
52 %mul = mul nsw i32 %tmp14, %tmp21
53 %add23 = add nsw i32 %sum.1, %mul
54 %indvar.next = add i64 %indvar, 1
57 for.end: ; preds = %for.cond5
58 %sum.1.lcssa = phi i32 [ %sum.1, %for.cond5 ]
61 for.inc25: ; preds = %for.end
62 %indvar.next2 = add i64 %indvar1, 1
65 for.end28: ; preds = %for.cond1
66 %sum.0.lcssa = phi i32 [ %sum.0, %for.cond1 ]
67 store i32 %sum.0.lcssa, i32* %arrayidx32, align 4
70 for.inc33: ; preds = %for.end28
71 %indvar.next4 = add i64 %indvar3, 1
74 for.end36: ; preds = %for.cond
78 define i32 @main() nounwind uwtable {
80 call void @check_vect()
83 for.cond: ; preds = %for.inc28, %entry
84 %indvar3 = phi i64 [ %indvar.next4, %for.inc28 ], [ 0, %entry ]
85 %exitcond13 = icmp ne i64 %indvar3, 32
86 br i1 %exitcond13, label %for.body, label %for.end31
88 for.body: ; preds = %for.cond
91 for.cond1: ; preds = %for.inc, %for.body
92 %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %for.body ]
93 %tmp14 = add i64 %indvar3, %indvar1
94 %add = trunc i64 %tmp14 to i32
95 %arrayidx10 = getelementptr [64 x [32 x i32]]* @in, i64 0, i64 %indvar1, i64 %indvar3
96 %exitcond = icmp ne i64 %indvar1, 64
97 br i1 %exitcond, label %for.body4, label %for.end
99 for.body4: ; preds = %for.cond1
100 store i32 %add, i32* %arrayidx10, align 4
103 for.inc: ; preds = %for.body4
104 %indvar.next2 = add i64 %indvar1, 1
107 for.end: ; preds = %for.cond1
110 for.cond12: ; preds = %for.inc24, %for.end
111 %indvar7 = phi i64 [ %indvar.next8, %for.inc24 ], [ 0, %for.end ]
112 %arrayidx23 = getelementptr [32 x [32 x i32]]* @coeff, i64 0, i64 %indvar7, i64 %indvar3
113 %tmp10 = add i64 %indvar7, 2
114 %add17 = trunc i64 %tmp10 to i32
115 %exitcond9 = icmp ne i64 %indvar7, 32
116 br i1 %exitcond9, label %for.body15, label %for.end27
118 for.body15: ; preds = %for.cond12
119 store i32 %add17, i32* %arrayidx23, align 4
122 for.inc24: ; preds = %for.body15
123 %indvar.next8 = add i64 %indvar7, 1
126 for.end27: ; preds = %for.cond12
129 for.inc28: ; preds = %for.end27
130 %indvar.next4 = add i64 %indvar3, 1
133 for.end31: ; preds = %for.cond
137 for.cond32: ; preds = %for.inc45, %for.end31
138 %indvar = phi i64 [ %indvar.next, %for.inc45 ], [ 0, %for.end31 ]
139 %arrayidx42 = getelementptr [32 x i32]* @check_result, i64 0, i64 %indvar
140 %arrayidx38 = getelementptr [32 x i32]* @out, i64 0, i64 %indvar
141 %k.0 = trunc i64 %indvar to i32
142 %cmp34 = icmp slt i32 %k.0, 32
143 br i1 %cmp34, label %for.body35, label %for.end48
145 for.body35: ; preds = %for.cond32
146 %tmp39 = load i32* %arrayidx38, align 4
147 %tmp43 = load i32* %arrayidx42, align 4
148 %cmp44 = icmp eq i32 %tmp39, %tmp43
149 br i1 %cmp44, label %if.end, label %if.then
151 if.then: ; preds = %for.body35
152 call void @abort() noreturn nounwind
155 if.end: ; preds = %for.body35
158 for.inc45: ; preds = %if.end
159 %indvar.next = add i64 %indvar, 1
162 for.end48: ; preds = %for.cond32
166 define internal void @check_vect() nounwind uwtable noinline {
168 %a = alloca i32, align 4
169 %b = alloca i32, align 4
170 %c = alloca i32, align 4
171 %d = alloca i32, align 4
172 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
173 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
174 %tobool = icmp eq i32 %call1, 0
175 br i1 %tobool, label %if.then, label %lor.lhs.false
177 lor.lhs.false: ; preds = %entry
178 %tmp4 = load i32* %d, align 4
179 %and6 = and i32 %tmp4, 67108864
180 %cmp = icmp eq i32 %and6, 0
181 br i1 %cmp, label %if.then, label %if.end
183 if.then: ; preds = %entry, %lor.lhs.false
184 call void @exit(i32 0) noreturn nounwind
187 if.end: ; preds = %lor.lhs.false
188 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
192 declare void @abort() noreturn
194 declare void (i32)* @signal(i32, void (i32)*) nounwind
196 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
198 call void @exit(i32 0) noreturn nounwind
201 return: ; No predecessors!
205 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
207 %and = and i32 %__level, -2147483648
208 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
209 %cmp = icmp ult i32 %call, %__level
210 br i1 %cmp, label %if.then, label %if.end
212 if.then: ; preds = %entry
215 if.end: ; preds = %entry
216 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
217 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
218 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
219 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
220 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
221 store i32 %asmresult, i32* %__eax, align 4
222 store i32 %asmresult8, i32* %__ebx, align 4
223 store i32 %asmresult9, i32* %__ecx, align 4
224 store i32 %asmresult10, i32* %__edx, align 4
227 return: ; preds = %if.end, %if.then
228 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
232 declare void @exit(i32) noreturn
234 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
236 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
237 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
238 %tobool = icmp eq i32* %__sig, null
239 br i1 %tobool, label %if.end, label %if.then
241 if.then: ; preds = %entry
242 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
243 store i32 %asmresult1, i32* %__sig, align 4
246 if.end: ; preds = %entry, %if.then
250 !0 = metadata !{i32 -2147343101, i32 -2147343093}
251 !1 = metadata !{i32 -2147343224, i32 -2147343216}