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-outer-2c.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-outer-2c.s > vect-outer-2c.ll
6 ; ModuleID = 'vect-outer-2c.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 @image = common global [80 x [80 x [40 x float]]] zeroinitializer, align 16
12 define void @foo() nounwind uwtable noinline {
16 for.cond: ; preds = %for.inc25, %entry
17 %indvar1 = phi i64 [ %indvar.next2, %for.inc25 ], [ 0, %entry ]
18 %exitcond15 = icmp ne i64 %indvar1, 40
19 br i1 %exitcond15, label %for.body, label %for.end28
21 for.body: ; preds = %for.cond
24 for.cond1: ; preds = %for.inc22, %for.body
25 %indvar3 = phi i64 [ %indvar.next4, %for.inc22 ], [ 0, %for.body ]
26 %tmp16 = add i64 %indvar1, %indvar3
27 %exitcond9 = icmp ne i64 %indvar3, 40
28 br i1 %exitcond9, label %for.body4, label %for.end24
30 for.body4: ; preds = %for.cond1
33 for.cond5: ; preds = %for.inc, %for.body4
34 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %for.body4 ]
35 %tmp = mul i64 %indvar, 2
36 %arrayidx19 = getelementptr [80 x [80 x [40 x float]]]* @image, i64 0, i64 %indvar1, i64 %tmp, i64 %indvar3
37 %tmp17 = add i64 %tmp16, %tmp
38 %add12 = trunc i64 %tmp17 to i32
39 %exitcond = icmp ne i64 %indvar, 20
40 br i1 %exitcond, label %for.body8, label %for.end
42 for.body8: ; preds = %for.cond5
43 %conv = sitofp i32 %add12 to float
44 store float %conv, float* %arrayidx19, align 4
47 for.inc: ; preds = %for.body8
48 %indvar.next = add i64 %indvar, 1
51 for.end: ; preds = %for.cond5
54 for.inc22: ; preds = %for.end
55 %indvar.next4 = add i64 %indvar3, 1
58 for.end24: ; preds = %for.cond1
61 for.inc25: ; preds = %for.end24
62 %indvar.next2 = add i64 %indvar1, 1
65 for.end28: ; preds = %for.cond
69 define i32 @main() nounwind uwtable {
71 call void @check_vect()
75 for.cond: ; preds = %for.inc28, %entry
76 %indvar3 = phi i64 [ %indvar.next4, %for.inc28 ], [ 0, %entry ]
77 %k.0 = trunc i64 %indvar3 to i32
78 %cmp = icmp slt i32 %k.0, 40
79 br i1 %cmp, label %for.body, label %for.end31
81 for.body: ; preds = %for.cond
84 for.cond1: ; preds = %for.inc25, %for.body
85 %indvar1 = phi i64 [ %indvar.next2, %for.inc25 ], [ 0, %for.body ]
86 %tmp15 = add i64 %indvar3, %indvar1
87 %i.0 = trunc i64 %indvar1 to i32
88 %cmp3 = icmp slt i32 %i.0, 40
89 br i1 %cmp3, label %for.body4, label %for.end27
91 for.body4: ; preds = %for.cond1
94 for.cond5: ; preds = %for.inc, %for.body4
95 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %for.body4 ]
96 %tmp14 = mul i64 %indvar, 2
97 %tmp17 = add i64 %tmp15, %tmp14
98 %add20 = trunc i64 %tmp17 to i32
99 %arrayidx15 = getelementptr [80 x [80 x [40 x float]]]* @image, i64 0, i64 %indvar3, i64 %tmp14, i64 %indvar1
100 %tmp = mul i64 %indvar, 2
101 %j.0 = trunc i64 %tmp to i32
102 %cmp7 = icmp slt i32 %j.0, 40
103 br i1 %cmp7, label %for.body8, label %for.end
105 for.body8: ; preds = %for.cond5
106 %tmp16 = load float* %arrayidx15, align 4
107 %conv = sitofp i32 %add20 to float
108 %cmp21 = fcmp une float %tmp16, %conv
109 br i1 %cmp21, label %if.then, label %if.end
111 if.then: ; preds = %for.body8
112 call void @abort() noreturn nounwind
115 if.end: ; preds = %for.body8
118 for.inc: ; preds = %if.end
119 %indvar.next = add i64 %indvar, 1
122 for.end: ; preds = %for.cond5
125 for.inc25: ; preds = %for.end
126 %indvar.next2 = add i64 %indvar1, 1
129 for.end27: ; preds = %for.cond1
132 for.inc28: ; preds = %for.end27
133 %indvar.next4 = add i64 %indvar3, 1
136 for.end31: ; preds = %for.cond
140 define internal void @check_vect() nounwind uwtable noinline {
142 %a = alloca i32, align 4
143 %b = alloca i32, align 4
144 %c = alloca i32, align 4
145 %d = alloca i32, align 4
146 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
147 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
148 %tobool = icmp eq i32 %call1, 0
149 br i1 %tobool, label %if.then, label %lor.lhs.false
151 lor.lhs.false: ; preds = %entry
152 %tmp4 = load i32* %d, align 4
153 %and6 = and i32 %tmp4, 67108864
154 %cmp = icmp eq i32 %and6, 0
155 br i1 %cmp, label %if.then, label %if.end
157 if.then: ; preds = %entry, %lor.lhs.false
158 call void @exit(i32 0) noreturn nounwind
161 if.end: ; preds = %lor.lhs.false
162 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
166 declare void @abort() noreturn
168 declare void (i32)* @signal(i32, void (i32)*) nounwind
170 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
172 call void @exit(i32 0) noreturn nounwind
175 return: ; No predecessors!
179 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
181 %and = and i32 %__level, -2147483648
182 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
183 %cmp = icmp ult i32 %call, %__level
184 br i1 %cmp, label %if.then, label %if.end
186 if.then: ; preds = %entry
189 if.end: ; preds = %entry
190 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
191 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
192 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
193 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
194 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
195 store i32 %asmresult, i32* %__eax, align 4
196 store i32 %asmresult8, i32* %__ebx, align 4
197 store i32 %asmresult9, i32* %__ecx, align 4
198 store i32 %asmresult10, i32* %__edx, align 4
201 return: ; preds = %if.end, %if.then
202 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
206 declare void @exit(i32) noreturn
208 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
210 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
211 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
212 %tobool = icmp eq i32* %__sig, null
213 br i1 %tobool, label %if.end, label %if.then
215 if.then: ; preds = %entry
216 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
217 store i32 %asmresult1, i32* %__sig, align 4
220 if.end: ; preds = %entry, %if.then
224 !0 = metadata !{i32 -2147343554, i32 -2147343546}
225 !1 = metadata !{i32 -2147343677, i32 -2147343669}