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-6.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-double-reduc-6.s > vect-double-reduc-6.ll
6 ; ModuleID = 'vect-double-reduc-6.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 [4 x i32] [i32 0, i32 16, i32 256, i32 4096], align 16
11 @in = common global [8 x [4 x i32]] zeroinitializer, align 16
12 @out = common global [4 x i32] zeroinitializer, align 16
14 define void @foo() nounwind uwtable noinline {
18 for.cond: ; preds = %for.inc25, %entry
19 %indvar1 = phi i64 [ %indvar.next2, %for.inc25 ], [ 0, %entry ]
20 %arrayidx24 = getelementptr [4 x i32]* @out, i64 0, i64 %indvar1
21 %exitcond9 = icmp ne i64 %indvar1, 4
22 br i1 %exitcond9, label %for.body, label %for.end28
24 for.body: ; preds = %for.cond
27 for.cond1: ; preds = %for.inc17, %for.body
28 %indvar3 = phi i64 [ %indvar.next4, %for.inc17 ], [ 0, %for.body ]
29 %sum.0 = phi i32 [ 1, %for.body ], [ %sum.1.lcssa, %for.inc17 ]
30 %exitcond6 = icmp ne i64 %indvar3, 4
31 br i1 %exitcond6, label %for.body4, label %for.end20
33 for.body4: ; preds = %for.cond1
36 for.cond5: ; preds = %for.inc, %for.body4
37 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %for.body4 ]
38 %sum.1 = phi i32 [ %sum.0, %for.body4 ], [ %mul, %for.inc ]
39 %tmp = add i64 %indvar1, %indvar
40 %arrayidx13 = getelementptr [8 x [4 x i32]]* @in, i64 0, i64 %tmp, i64 %indvar3
41 %exitcond = icmp ne i64 %indvar, 4
42 br i1 %exitcond, label %for.body8, label %for.end
44 for.body8: ; preds = %for.cond5
47 for.inc: ; preds = %for.body8
48 %tmp14 = load i32* %arrayidx13, align 4
49 %mul = mul nsw i32 %sum.1, %tmp14
50 %indvar.next = add i64 %indvar, 1
53 for.end: ; preds = %for.cond5
54 %sum.1.lcssa = phi i32 [ %sum.1, %for.cond5 ]
57 for.inc17: ; preds = %for.end
58 %indvar.next4 = add i64 %indvar3, 1
61 for.end20: ; preds = %for.cond1
62 %sum.0.lcssa = phi i32 [ %sum.0, %for.cond1 ]
63 store i32 %sum.0.lcssa, i32* %arrayidx24, align 4
66 for.inc25: ; preds = %for.end20
67 %indvar.next2 = add i64 %indvar1, 1
70 for.end28: ; preds = %for.cond
74 define i32 @main() nounwind uwtable {
76 call void @check_vect()
79 for.cond: ; preds = %for.inc11, %entry
80 %indvar3 = phi i64 [ %indvar.next4, %for.inc11 ], [ 0, %entry ]
81 %tmp = add i64 %indvar3, 2
82 %add = trunc i64 %tmp to i32
83 %exitcond5 = icmp ne i64 %indvar3, 8
84 br i1 %exitcond5, label %for.body, label %for.end14
86 for.body: ; preds = %for.cond
89 for.cond1: ; preds = %for.inc, %for.body
90 %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %for.body ]
91 %arrayidx9 = getelementptr [8 x [4 x i32]]* @in, i64 0, i64 %indvar3, i64 %indvar1
92 %exitcond = icmp ne i64 %indvar1, 4
93 br i1 %exitcond, label %for.body4, label %for.end
95 for.body4: ; preds = %for.cond1
96 %div = sdiv i32 %add, 3
97 store i32 %div, i32* %arrayidx9, align 4
100 for.inc: ; preds = %for.body4
101 %indvar.next2 = add i64 %indvar1, 1
104 for.end: ; preds = %for.cond1
107 for.inc11: ; preds = %for.end
108 %indvar.next4 = add i64 %indvar3, 1
111 for.end14: ; preds = %for.cond
115 for.cond15: ; preds = %for.inc28, %for.end14
116 %indvar = phi i64 [ %indvar.next, %for.inc28 ], [ 0, %for.end14 ]
117 %arrayidx25 = getelementptr [4 x i32]* @check_result, i64 0, i64 %indvar
118 %arrayidx21 = getelementptr [4 x i32]* @out, i64 0, i64 %indvar
119 %k.0 = trunc i64 %indvar to i32
120 %cmp17 = icmp slt i32 %k.0, 4
121 br i1 %cmp17, label %for.body18, label %for.end31
123 for.body18: ; preds = %for.cond15
124 %tmp22 = load i32* %arrayidx21, align 4
125 %tmp26 = load i32* %arrayidx25, align 4
126 %cmp27 = icmp eq i32 %tmp22, %tmp26
127 br i1 %cmp27, label %if.end, label %if.then
129 if.then: ; preds = %for.body18
130 call void @abort() noreturn nounwind
133 if.end: ; preds = %for.body18
136 for.inc28: ; preds = %if.end
137 %indvar.next = add i64 %indvar, 1
140 for.end31: ; preds = %for.cond15
144 define internal void @check_vect() nounwind uwtable noinline {
146 %a = alloca i32, align 4
147 %b = alloca i32, align 4
148 %c = alloca i32, align 4
149 %d = alloca i32, align 4
150 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
151 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
152 %tobool = icmp eq i32 %call1, 0
153 br i1 %tobool, label %if.then, label %lor.lhs.false
155 lor.lhs.false: ; preds = %entry
156 %tmp4 = load i32* %d, align 4
157 %and6 = and i32 %tmp4, 67108864
158 %cmp = icmp eq i32 %and6, 0
159 br i1 %cmp, label %if.then, label %if.end
161 if.then: ; preds = %entry, %lor.lhs.false
162 call void @exit(i32 0) noreturn nounwind
165 if.end: ; preds = %lor.lhs.false
166 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
170 declare void @abort() noreturn
172 declare void (i32)* @signal(i32, void (i32)*) nounwind
174 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
176 call void @exit(i32 0) noreturn nounwind
179 return: ; No predecessors!
183 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
185 %and = and i32 %__level, -2147483648
186 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
187 %cmp = icmp ult i32 %call, %__level
188 br i1 %cmp, label %if.then, label %if.end
190 if.then: ; preds = %entry
193 if.end: ; preds = %entry
194 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
195 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
196 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
197 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
198 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
199 store i32 %asmresult, i32* %__eax, align 4
200 store i32 %asmresult8, i32* %__ebx, align 4
201 store i32 %asmresult9, i32* %__ecx, align 4
202 store i32 %asmresult10, i32* %__edx, align 4
205 return: ; preds = %if.end, %if.then
206 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
210 declare void @exit(i32) noreturn
212 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
214 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
215 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
216 %tobool = icmp eq i32* %__sig, null
217 br i1 %tobool, label %if.end, label %if.then
219 if.then: ; preds = %entry
220 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
221 store i32 %asmresult1, i32* %__sig, align 4
224 if.end: ; preds = %entry, %if.then
228 !0 = metadata !{i32 -2147343479, i32 -2147343471}
229 !1 = metadata !{i32 -2147343602, i32 -2147343594}