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-2a.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-outer-2a.s > vect-outer-2a.ll
6 ; ModuleID = 'vect-outer-2a.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 [40 x [40 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 %exitcond13 = icmp ne i64 %indvar1, 40
19 br i1 %exitcond13, label %for.body, label %for.end28
21 for.body: ; preds = %for.cond
24 for.cond1: ; preds = %for.inc21, %for.body
25 %indvar3 = phi i64 [ %indvar.next4, %for.inc21 ], [ 0, %for.body ]
26 %tmp = add i64 %indvar1, %indvar3
27 %exitcond8 = icmp ne i64 %indvar3, 40
28 br i1 %exitcond8, 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 %arrayidx19 = getelementptr [40 x [40 x [40 x float]]]* @image, i64 0, i64 %indvar1, i64 %indvar, i64 %indvar3
36 %tmp14 = add i64 %tmp, %indvar
37 %add12 = trunc i64 %tmp14 to i32
38 %exitcond = icmp ne i64 %indvar, 40
39 br i1 %exitcond, label %for.body8, label %for.end
41 for.body8: ; preds = %for.cond5
42 %conv = sitofp i32 %add12 to float
43 store float %conv, float* %arrayidx19, align 4
46 for.inc: ; preds = %for.body8
47 %indvar.next = add i64 %indvar, 1
50 for.end: ; preds = %for.cond5
53 for.inc21: ; preds = %for.end
54 %indvar.next4 = add i64 %indvar3, 1
57 for.end24: ; preds = %for.cond1
60 for.inc25: ; preds = %for.end24
61 %indvar.next2 = add i64 %indvar1, 1
64 for.end28: ; preds = %for.cond
68 define i32 @main() nounwind uwtable {
70 call void @check_vect()
74 for.cond: ; preds = %for.inc28, %entry
75 %indvar3 = phi i64 [ %indvar.next4, %for.inc28 ], [ 0, %entry ]
76 %k.0 = trunc i64 %indvar3 to i32
77 %cmp = icmp slt i32 %k.0, 40
78 br i1 %cmp, label %for.body, label %for.end31
80 for.body: ; preds = %for.cond
83 for.cond1: ; preds = %for.inc24, %for.body
84 %indvar1 = phi i64 [ %indvar.next2, %for.inc24 ], [ 0, %for.body ]
85 %tmp = add i64 %indvar3, %indvar1
86 %i.0 = trunc i64 %indvar1 to i32
87 %cmp3 = icmp slt i32 %i.0, 40
88 br i1 %cmp3, label %for.body4, label %for.end27
90 for.body4: ; preds = %for.cond1
93 for.cond5: ; preds = %for.inc, %for.body4
94 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %for.body4 ]
95 %tmp12 = add i64 %tmp, %indvar
96 %add20 = trunc i64 %tmp12 to i32
97 %arrayidx15 = getelementptr [40 x [40 x [40 x float]]]* @image, i64 0, i64 %indvar3, i64 %indvar, i64 %indvar1
98 %j.0 = trunc i64 %indvar to i32
99 %cmp7 = icmp slt i32 %j.0, 40
100 br i1 %cmp7, label %for.body8, label %for.end
102 for.body8: ; preds = %for.cond5
103 %tmp16 = load float* %arrayidx15, align 4
104 %conv = sitofp i32 %add20 to float
105 %cmp21 = fcmp une float %tmp16, %conv
106 br i1 %cmp21, label %if.then, label %if.end
108 if.then: ; preds = %for.body8
109 call void @abort() noreturn nounwind
112 if.end: ; preds = %for.body8
115 for.inc: ; preds = %if.end
116 %indvar.next = add i64 %indvar, 1
119 for.end: ; preds = %for.cond5
122 for.inc24: ; preds = %for.end
123 %indvar.next2 = add i64 %indvar1, 1
126 for.end27: ; preds = %for.cond1
129 for.inc28: ; preds = %for.end27
130 %indvar.next4 = add i64 %indvar3, 1
133 for.end31: ; preds = %for.cond
137 define internal void @check_vect() nounwind uwtable noinline {
139 %a = alloca i32, align 4
140 %b = alloca i32, align 4
141 %c = alloca i32, align 4
142 %d = alloca i32, align 4
143 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
144 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
145 %tobool = icmp eq i32 %call1, 0
146 br i1 %tobool, label %if.then, label %lor.lhs.false
148 lor.lhs.false: ; preds = %entry
149 %tmp4 = load i32* %d, align 4
150 %and6 = and i32 %tmp4, 67108864
151 %cmp = icmp eq i32 %and6, 0
152 br i1 %cmp, label %if.then, label %if.end
154 if.then: ; preds = %entry, %lor.lhs.false
155 call void @exit(i32 0) noreturn nounwind
158 if.end: ; preds = %lor.lhs.false
159 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
163 declare void @abort() noreturn
165 declare void (i32)* @signal(i32, void (i32)*) nounwind
167 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
169 call void @exit(i32 0) noreturn nounwind
172 return: ; No predecessors!
176 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
178 %and = and i32 %__level, -2147483648
179 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
180 %cmp = icmp ult i32 %call, %__level
181 br i1 %cmp, label %if.then, label %if.end
183 if.then: ; preds = %entry
186 if.end: ; preds = %entry
187 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
188 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
189 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
190 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
191 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
192 store i32 %asmresult, i32* %__eax, align 4
193 store i32 %asmresult8, i32* %__ebx, align 4
194 store i32 %asmresult9, i32* %__ecx, align 4
195 store i32 %asmresult10, i32* %__edx, align 4
198 return: ; preds = %if.end, %if.then
199 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
203 declare void @exit(i32) noreturn
205 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
207 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
208 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
209 %tobool = icmp eq i32* %__sig, null
210 br i1 %tobool, label %if.end, label %if.then
212 if.then: ; preds = %entry
213 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
214 store i32 %asmresult1, i32* %__sig, align 4
217 if.end: ; preds = %entry, %if.then
221 !0 = metadata !{i32 -2147343560, i32 -2147343552}
222 !1 = metadata !{i32 -2147343683, i32 -2147343675}