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-3.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-outer-3.s > vect-outer-3.ll
6 ; ModuleID = 'vect-outer-3.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 float]] zeroinitializer, align 16
11 @out = common global [40 x float] zeroinitializer, align 16
13 define void @foo() nounwind uwtable noinline {
17 for.cond: ; preds = %for.inc16, %entry
18 %indvar1 = phi i64 [ %indvar.next2, %for.inc16 ], [ 0, %entry ]
19 %arrayidx15 = getelementptr [40 x float]* @out, i64 0, i64 %indvar1
20 %exitcond3 = icmp ne i64 %indvar1, 40
21 br i1 %exitcond3, label %for.body, label %for.end19
23 for.body: ; preds = %for.cond
26 for.cond1: ; preds = %for.inc, %for.body
27 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %for.body ]
28 %diff.0 = phi float [ 0.000000e+00, %for.body ], [ %add, %for.inc ]
29 %arrayidx8 = getelementptr [40 x [40 x float]]* @image, i64 0, i64 %indvar, i64 %indvar1
30 %exitcond = icmp ne i64 %indvar, 40
31 br i1 %exitcond, label %for.body4, label %for.end
33 for.body4: ; preds = %for.cond1
36 for.inc: ; preds = %for.body4
37 %tmp9 = load float* %arrayidx8, align 4
38 %add = fadd float %diff.0, %tmp9
39 %indvar.next = add i64 %indvar, 1
42 for.end: ; preds = %for.cond1
43 %diff.0.lcssa = phi float [ %diff.0, %for.cond1 ]
44 store float %diff.0.lcssa, float* %arrayidx15, align 4
47 for.inc16: ; preds = %for.end
48 %indvar.next2 = add i64 %indvar1, 1
51 for.end19: ; preds = %for.cond
55 define i32 @main() nounwind uwtable {
57 call void @check_vect()
60 for.cond: ; preds = %for.inc12, %entry
61 %indvar6 = phi i64 [ %indvar.next7, %for.inc12 ], [ 0, %entry ]
62 %exitcond10 = icmp ne i64 %indvar6, 40
63 br i1 %exitcond10, label %for.body, label %for.end15
65 for.body: ; preds = %for.cond
68 for.cond1: ; preds = %for.inc, %for.body
69 %indvar3 = phi i64 [ %indvar.next4, %for.inc ], [ 0, %for.body ]
70 %tmp11 = add i64 %indvar6, %indvar3
71 %add = trunc i64 %tmp11 to i32
72 %arrayidx10 = getelementptr [40 x [40 x float]]* @image, i64 0, i64 %indvar6, i64 %indvar3
73 %exitcond5 = icmp ne i64 %indvar3, 40
74 br i1 %exitcond5, label %for.body4, label %for.end
76 for.body4: ; preds = %for.cond1
77 %conv = sitofp i32 %add to float
78 store float %conv, float* %arrayidx10, align 4
81 for.inc: ; preds = %for.body4
82 %indvar.next4 = add i64 %indvar3, 1
85 for.end: ; preds = %for.cond1
88 for.inc12: ; preds = %for.end
89 %indvar.next7 = add i64 %indvar6, 1
92 for.end15: ; preds = %for.cond
96 for.cond16: ; preds = %for.inc46, %for.end15
97 %indvar1 = phi i64 [ %indvar.next2, %for.inc46 ], [ 0, %for.end15 ]
98 %arrayidx41 = getelementptr [40 x float]* @out, i64 0, i64 %indvar1
99 %i.1 = trunc i64 %indvar1 to i32
100 %cmp18 = icmp slt i32 %i.1, 40
101 br i1 %cmp18, label %for.body20, label %for.end49
103 for.body20: ; preds = %for.cond16
106 for.cond21: ; preds = %for.inc35, %for.body20
107 %indvar = phi i64 [ %indvar.next, %for.inc35 ], [ 0, %for.body20 ]
108 %diff.0 = phi float [ 0.000000e+00, %for.body20 ], [ %add34, %for.inc35 ]
109 %arrayidx31 = getelementptr [40 x [40 x float]]* @image, i64 0, i64 %indvar, i64 %indvar1
110 %exitcond = icmp ne i64 %indvar, 40
111 br i1 %exitcond, label %for.body25, label %for.end38
113 for.body25: ; preds = %for.cond21
116 for.inc35: ; preds = %for.body25
117 %tmp32 = load float* %arrayidx31, align 4
118 %add34 = fadd float %diff.0, %tmp32
119 %indvar.next = add i64 %indvar, 1
122 for.end38: ; preds = %for.cond21
123 %diff.0.lcssa = phi float [ %diff.0, %for.cond21 ]
124 %tmp42 = load float* %arrayidx41, align 4
125 %cmp44 = fcmp une float %tmp42, %diff.0.lcssa
126 br i1 %cmp44, label %if.then, label %if.end
128 if.then: ; preds = %for.end38
129 call void @abort() noreturn nounwind
132 if.end: ; preds = %for.end38
135 for.inc46: ; preds = %if.end
136 %indvar.next2 = add i64 %indvar1, 1
139 for.end49: ; preds = %for.cond16
143 define internal void @check_vect() nounwind uwtable noinline {
145 %a = alloca i32, align 4
146 %b = alloca i32, align 4
147 %c = alloca i32, align 4
148 %d = alloca i32, align 4
149 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
150 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
151 %tobool = icmp eq i32 %call1, 0
152 br i1 %tobool, label %if.then, label %lor.lhs.false
154 lor.lhs.false: ; preds = %entry
155 %tmp4 = load i32* %d, align 4
156 %and6 = and i32 %tmp4, 67108864
157 %cmp = icmp eq i32 %and6, 0
158 br i1 %cmp, label %if.then, label %if.end
160 if.then: ; preds = %entry, %lor.lhs.false
161 call void @exit(i32 0) noreturn nounwind
164 if.end: ; preds = %lor.lhs.false
165 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
169 declare void @abort() noreturn
171 declare void (i32)* @signal(i32, void (i32)*) nounwind
173 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
175 call void @exit(i32 0) noreturn nounwind
178 return: ; No predecessors!
182 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
184 %and = and i32 %__level, -2147483648
185 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
186 %cmp = icmp ult i32 %call, %__level
187 br i1 %cmp, label %if.then, label %if.end
189 if.then: ; preds = %entry
192 if.end: ; preds = %entry
193 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
194 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
195 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
196 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
197 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
198 store i32 %asmresult, i32* %__eax, align 4
199 store i32 %asmresult8, i32* %__ebx, align 4
200 store i32 %asmresult9, i32* %__ecx, align 4
201 store i32 %asmresult10, i32* %__edx, align 4
204 return: ; preds = %if.end, %if.then
205 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
209 declare void @exit(i32) noreturn
211 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
213 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
214 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
215 %tobool = icmp eq i32* %__sig, null
216 br i1 %tobool, label %if.end, label %if.then
218 if.then: ; preds = %entry
219 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
220 store i32 %asmresult1, i32* %__sig, align 4
223 if.end: ; preds = %entry, %if.then
227 !0 = metadata !{i32 -2147343446, i32 -2147343438}
228 !1 = metadata !{i32 -2147343569, i32 -2147343561}