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-5.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-outer-5.s > vect-outer-5.ll
6 ; ModuleID = 'vect-outer-5.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 @main1.E = internal unnamed_addr constant [4 x float] [float 0.000000e+00, float 4.800000e+02, float 9.600000e+02, float 1.440000e+03], align 16
12 define i32 @main1() nounwind uwtable noinline {
14 %A = alloca [64 x float], align 16
15 %B = alloca [64 x float], align 16
16 %C = alloca [64 x float], align 16
17 %D = alloca [64 x float], align 16
18 %E = alloca [4 x float], align 16
19 %tmp = bitcast [4 x float]* %E to i8*
20 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp, i8* bitcast ([4 x float]* @main1.E to i8*), i64 16, i32 16, i1 false)
23 for.cond: ; preds = %for.inc, %entry
24 %indvar30 = phi i64 [ %indvar.next31, %for.inc ], [ 0, %entry ]
25 %arrayidx21 = getelementptr [64 x float]* %D, i64 0, i64 %indvar30
26 %i.0 = trunc i64 %indvar30 to i32
27 %arrayidx16 = getelementptr [64 x float]* %C, i64 0, i64 %indvar30
28 %arrayidx11 = getelementptr [64 x float]* %B, i64 0, i64 %indvar30
29 %arrayidx = getelementptr [64 x float]* %A, i64 0, i64 %indvar30
30 %exitcond32 = icmp ne i64 %indvar30, 64
31 br i1 %exitcond32, label %for.body, label %for.end
33 for.body: ; preds = %for.cond
34 %conv = sitofp i32 %i.0 to float
35 store float %conv, float* %arrayidx, align 4
36 %conv8 = sitofp i32 %i.0 to float
37 store float %conv8, float* %arrayidx11, align 4
38 %conv13 = sitofp i32 %i.0 to float
39 store float %conv13, float* %arrayidx16, align 4
40 %conv18 = sitofp i32 %i.0 to float
41 store float %conv18, float* %arrayidx21, align 4
44 for.inc: ; preds = %for.body
45 %indvar.next31 = add i64 %indvar30, 1
48 for.end: ; preds = %for.cond
51 for.cond23: ; preds = %for.inc52, %for.end
52 %indvar25 = phi i64 [ %indvar.next26, %for.inc52 ], [ 0, %for.end ]
53 %arrayidx51 = getelementptr [64 x float]* %A, i64 0, i64 %indvar25
54 %tmp28 = add i64 %indvar25, 20
55 %arrayidx45 = getelementptr [64 x float]* %A, i64 0, i64 %tmp28
56 %exitcond27 = icmp ne i64 %indvar25, 44
57 br i1 %exitcond27, label %for.body27, label %for.end55
59 for.body27: ; preds = %for.cond23
62 for.cond28: ; preds = %for.inc38, %for.body27
63 %indvar20 = phi i64 [ %indvar.next21, %for.inc38 ], [ 0, %for.body27 ]
64 %s.0 = phi float [ 0.000000e+00, %for.body27 ], [ %add, %for.inc38 ]
65 %tmp23 = mul i64 %indvar20, 4
66 %arrayidx35 = getelementptr [64 x float]* %C, i64 0, i64 %tmp23
67 %exitcond22 = icmp ne i64 %indvar20, 16
68 br i1 %exitcond22, label %for.body32, label %for.end41
70 for.body32: ; preds = %for.cond28
73 for.inc38: ; preds = %for.body32
74 %tmp36 = load float* %arrayidx35, align 16
75 %add = fadd float %s.0, %tmp36
76 %indvar.next21 = add i64 %indvar20, 1
79 for.end41: ; preds = %for.cond28
80 %s.0.lcssa = phi float [ %s.0, %for.cond28 ]
81 %tmp46 = load float* %arrayidx45, align 4
82 %add48 = fadd float %tmp46, %s.0.lcssa
83 store float %add48, float* %arrayidx51, align 4
86 for.inc52: ; preds = %for.end41
87 %indvar.next26 = add i64 %indvar25, 1
90 for.end55: ; preds = %for.cond23
93 for.cond56: ; preds = %for.inc89, %for.end55
94 %indvar16 = phi i64 [ %indvar.next17, %for.inc89 ], [ 0, %for.end55 ]
95 %tmp18 = add i64 %indvar16, 20
96 %arrayidx83 = getelementptr [64 x float]* %D, i64 0, i64 %tmp18
97 %arrayidx78 = getelementptr [64 x float]* %A, i64 0, i64 %indvar16
98 %i.2 = trunc i64 %indvar16 to i32
99 %cmp58 = icmp slt i32 %i.2, 44
100 br i1 %cmp58, label %for.body60, label %for.end92
102 for.body60: ; preds = %for.cond56
105 for.cond61: ; preds = %for.inc72, %for.body60
106 %indvar11 = phi i64 [ %indvar.next12, %for.inc72 ], [ 0, %for.body60 ]
107 %s.1 = phi float [ 0.000000e+00, %for.body60 ], [ %add71, %for.inc72 ]
108 %tmp14 = mul i64 %indvar11, 4
109 %arrayidx68 = getelementptr [64 x float]* %C, i64 0, i64 %tmp14
110 %exitcond13 = icmp ne i64 %indvar11, 16
111 br i1 %exitcond13, label %for.body65, label %for.end75
113 for.body65: ; preds = %for.cond61
116 for.inc72: ; preds = %for.body65
117 %tmp69 = load float* %arrayidx68, align 16
118 %add71 = fadd float %s.1, %tmp69
119 %indvar.next12 = add i64 %indvar11, 1
122 for.end75: ; preds = %for.cond61
123 %s.1.lcssa = phi float [ %s.1, %for.cond61 ]
124 %tmp79 = load float* %arrayidx78, align 4
125 %tmp84 = load float* %arrayidx83, align 4
126 %add86 = fadd float %tmp84, %s.1.lcssa
127 %cmp87 = fcmp une float %tmp79, %add86
128 br i1 %cmp87, label %if.then, label %if.end
130 if.then: ; preds = %for.end75
131 call void @abort() noreturn nounwind
134 if.end: ; preds = %for.end75
137 for.inc89: ; preds = %if.end
138 %indvar.next17 = add i64 %indvar16, 1
141 for.end92: ; preds = %for.cond56
144 for.cond93: ; preds = %for.inc123, %for.end92
145 %indvar6 = phi i64 [ %indvar.next7, %for.inc123 ], [ 0, %for.end92 ]
146 %tmp9 = add i64 %indvar6, 1
147 %arrayidx122 = getelementptr [64 x float]* %B, i64 0, i64 %tmp9
148 %arrayidx115 = getelementptr [64 x float]* %B, i64 0, i64 %indvar6
149 %exitcond8 = icmp ne i64 %indvar6, 4
150 br i1 %exitcond8, label %for.body97, label %for.end126
152 for.body97: ; preds = %for.cond93
155 for.cond98: ; preds = %for.inc109, %for.body97
156 %indvar2 = phi i64 [ %indvar.next3, %for.inc109 ], [ 0, %for.body97 ]
157 %s.2 = phi float [ 0.000000e+00, %for.body97 ], [ %add108, %for.inc109 ]
158 %tmp4 = mul i64 %indvar2, 4
159 %arrayidx105 = getelementptr [64 x float]* %C, i64 0, i64 %tmp4
160 %exitcond = icmp ne i64 %indvar2, 16
161 br i1 %exitcond, label %for.body102, label %for.end112
163 for.body102: ; preds = %for.cond98
166 for.inc109: ; preds = %for.body102
167 %tmp106 = load float* %arrayidx105, align 16
168 %add108 = fadd float %s.2, %tmp106
169 %indvar.next3 = add i64 %indvar2, 1
172 for.end112: ; preds = %for.cond98
173 %s.2.lcssa = phi float [ %s.2, %for.cond98 ]
174 %tmp116 = load float* %arrayidx115, align 4
175 %add118 = fadd float %tmp116, %s.2.lcssa
176 store float %add118, float* %arrayidx122, align 4
179 for.inc123: ; preds = %for.end112
180 %indvar.next7 = add i64 %indvar6, 1
183 for.end126: ; preds = %for.cond93
184 br label %for.cond127
186 for.cond127: ; preds = %for.inc144, %for.end126
187 %indvar = phi i64 [ %indvar.next, %for.inc144 ], [ 0, %for.end126 ]
188 %arrayidx138 = getelementptr [4 x float]* %E, i64 0, i64 %indvar
189 %arrayidx134 = getelementptr [64 x float]* %B, i64 0, i64 %indvar
190 %i.4 = trunc i64 %indvar to i32
191 %cmp129 = icmp slt i32 %i.4, 4
192 br i1 %cmp129, label %for.body131, label %for.end147
194 for.body131: ; preds = %for.cond127
195 %tmp135 = load float* %arrayidx134, align 4
196 %tmp139 = load float* %arrayidx138, align 4
197 %cmp140 = fcmp une float %tmp135, %tmp139
198 br i1 %cmp140, label %if.then142, label %if.end143
200 if.then142: ; preds = %for.body131
201 call void @abort() noreturn nounwind
204 if.end143: ; preds = %for.body131
207 for.inc144: ; preds = %if.end143
208 %indvar.next = add i64 %indvar, 1
209 br label %for.cond127
211 for.end147: ; preds = %for.cond127
215 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
217 declare void @abort() noreturn
219 define i32 @main() nounwind uwtable {
221 call void @check_vect()
222 %call = call i32 @main1()
226 define internal void @check_vect() nounwind uwtable noinline {
228 %a = alloca i32, align 4
229 %b = alloca i32, align 4
230 %c = alloca i32, align 4
231 %d = alloca i32, align 4
232 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
233 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
234 %tobool = icmp eq i32 %call1, 0
235 br i1 %tobool, label %if.then, label %lor.lhs.false
237 lor.lhs.false: ; preds = %entry
238 %tmp4 = load i32* %d, align 4
239 %and6 = and i32 %tmp4, 67108864
240 %cmp = icmp eq i32 %and6, 0
241 br i1 %cmp, label %if.then, label %if.end
243 if.then: ; preds = %entry, %lor.lhs.false
244 call void @exit(i32 0) noreturn nounwind
247 if.end: ; preds = %lor.lhs.false
248 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
252 declare void (i32)* @signal(i32, void (i32)*) nounwind
254 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
256 call void @exit(i32 0) noreturn nounwind
259 return: ; No predecessors!
263 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
265 %and = and i32 %__level, -2147483648
266 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
267 %cmp = icmp ult i32 %call, %__level
268 br i1 %cmp, label %if.then, label %if.end
270 if.then: ; preds = %entry
273 if.end: ; preds = %entry
274 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
275 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
276 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
277 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
278 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
279 store i32 %asmresult, i32* %__eax, align 4
280 store i32 %asmresult8, i32* %__ebx, align 4
281 store i32 %asmresult9, i32* %__ecx, align 4
282 store i32 %asmresult10, i32* %__edx, align 4
285 return: ; preds = %if.end, %if.then
286 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
290 declare void @exit(i32) noreturn
292 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
294 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
295 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
296 %tobool = icmp eq i32* %__sig, null
297 br i1 %tobool, label %if.end, label %if.then
299 if.then: ; preds = %entry
300 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
301 store i32 %asmresult1, i32* %__sig, align 4
304 if.end: ; preds = %entry, %if.then
308 !0 = metadata !{i32 -2147342403, i32 -2147342395}
309 !1 = metadata !{i32 -2147342526, i32 -2147342518}