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-22.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-22.s > vect-22.ll
6 ; ModuleID = 'vect-22.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 @ib = global [64 x i32] [i32 1, i32 1, i32 0, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 1, i32 0, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 1, i32 0, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 1, i32 0, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 1, i32 0, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 1, i32 0, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 1, i32 0, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 1, i32 0, i32 0, i32 1, i32 0, i32 1, i32 0], align 16
11 @cb = global [64 x i8] c"\01\01\00\00\01\00\01\00\01\01\00\00\01\00\01\00\01\01\00\00\01\00\01\00\01\01\00\00\01\00\01\00\01\01\00\00\01\00\01\00\01\01\00\00\01\00\01\00\01\01\00\00\01\00\01\00\01\01\00\00\01\00\01\00", align 16
12 @sb = global [64 x i16] [i16 1, i16 1, i16 0, i16 0, i16 1, i16 0, i16 1, i16 0, i16 1, i16 1, i16 0, i16 0, i16 1, i16 0, i16 1, i16 0, i16 1, i16 1, i16 0, i16 0, i16 1, i16 0, i16 1, i16 0, i16 1, i16 1, i16 0, i16 0, i16 1, i16 0, i16 1, i16 0, i16 1, i16 1, i16 0, i16 0, i16 1, i16 0, i16 1, i16 0, i16 1, i16 1, i16 0, i16 0, i16 1, i16 0, i16 1, i16 0, i16 1, i16 1, i16 0, i16 0, i16 1, i16 0, i16 1, i16 0, i16 1, i16 1, i16 0, i16 0, i16 1, i16 0, i16 1, i16 0], align 16
13 @fb = global [64 x float] [float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 1.000000e+00, float 0.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00, float 1.000000e+00, float 0.000000e+00], align 16
14 @ia = common global [64 x i32] zeroinitializer, align 16
15 @ca = common global [64 x i8] zeroinitializer, align 16
16 @sa = common global [64 x i16] zeroinitializer, align 16
17 @fa = common global [64 x float] zeroinitializer, align 16
19 define i32 @main1() nounwind uwtable noinline {
23 for.cond: ; preds = %for.inc, %entry
24 %indvar17 = phi i64 [ %indvar.next18, %for.inc ], [ 0, %entry ]
25 %arrayidx5 = getelementptr [64 x i32]* @ia, i64 0, i64 %indvar17
26 %arrayidx = getelementptr [64 x i32]* @ib, i64 0, i64 %indvar17
27 %exitcond19 = icmp ne i64 %indvar17, 64
28 br i1 %exitcond19, label %for.body, label %for.end
30 for.body: ; preds = %for.cond
31 %tmp2 = load i32* %arrayidx, align 4
32 %sub = sub nsw i32 0, %tmp2
33 store i32 %sub, i32* %arrayidx5, align 4
36 for.inc: ; preds = %for.body
37 %indvar.next18 = add i64 %indvar17, 1
40 for.end: ; preds = %for.cond
43 for.cond7: ; preds = %for.inc21, %for.end
44 %indvar15 = phi i64 [ %indvar.next16, %for.inc21 ], [ 0, %for.end ]
45 %arrayidx17 = getelementptr [64 x i32]* @ib, i64 0, i64 %indvar15
46 %arrayidx13 = getelementptr [64 x i32]* @ia, i64 0, i64 %indvar15
47 %i.1 = trunc i64 %indvar15 to i32
48 %cmp9 = icmp slt i32 %i.1, 64
49 br i1 %cmp9, label %for.body10, label %for.end24
51 for.body10: ; preds = %for.cond7
52 %tmp14 = load i32* %arrayidx13, align 4
53 %tmp18 = load i32* %arrayidx17, align 4
54 %sub19 = sub nsw i32 0, %tmp18
55 %cmp20 = icmp eq i32 %tmp14, %sub19
56 br i1 %cmp20, label %if.end, label %if.then
58 if.then: ; preds = %for.body10
59 call void @abort() noreturn nounwind
62 if.end: ; preds = %for.body10
65 for.inc21: ; preds = %if.end
66 %indvar.next16 = add i64 %indvar15, 1
69 for.end24: ; preds = %for.cond7
72 for.cond25: ; preds = %for.inc38, %for.end24
73 %indvar12 = phi i64 [ %indvar.next13, %for.inc38 ], [ 0, %for.end24 ]
74 %arrayidx37 = getelementptr [64 x i8]* @ca, i64 0, i64 %indvar12
75 %arrayidx31 = getelementptr [64 x i8]* @cb, i64 0, i64 %indvar12
76 %exitcond14 = icmp ne i64 %indvar12, 64
77 br i1 %exitcond14, label %for.body28, label %for.end41
79 for.body28: ; preds = %for.cond25
80 %tmp32 = load i8* %arrayidx31, align 1
81 %sub33 = sub i8 0, %tmp32
82 store i8 %sub33, i8* %arrayidx37, align 1
85 for.inc38: ; preds = %for.body28
86 %indvar.next13 = add i64 %indvar12, 1
89 for.end41: ; preds = %for.cond25
92 for.cond42: ; preds = %for.inc62, %for.end41
93 %indvar10 = phi i64 [ %indvar.next11, %for.inc62 ], [ 0, %for.end41 ]
94 %arrayidx54 = getelementptr [64 x i8]* @cb, i64 0, i64 %indvar10
95 %arrayidx49 = getelementptr [64 x i8]* @ca, i64 0, i64 %indvar10
96 %i.3 = trunc i64 %indvar10 to i32
97 %cmp44 = icmp slt i32 %i.3, 64
98 br i1 %cmp44, label %for.body46, label %for.end65
100 for.body46: ; preds = %for.cond42
101 %tmp50 = load i8* %arrayidx49, align 1
102 %conv51 = sext i8 %tmp50 to i32
103 %tmp55 = load i8* %arrayidx54, align 1
104 %conv56 = sext i8 %tmp55 to i32
105 %sub57 = sub nsw i32 0, %conv56
106 %cmp58 = icmp eq i32 %conv51, %sub57
107 br i1 %cmp58, label %if.end61, label %if.then60
109 if.then60: ; preds = %for.body46
110 call void @abort() noreturn nounwind
113 if.end61: ; preds = %for.body46
116 for.inc62: ; preds = %if.end61
117 %indvar.next11 = add i64 %indvar10, 1
120 for.end65: ; preds = %for.cond42
123 for.cond66: ; preds = %for.inc81, %for.end65
124 %indvar7 = phi i64 [ %indvar.next8, %for.inc81 ], [ 0, %for.end65 ]
125 %arrayidx80 = getelementptr [64 x i16]* @sa, i64 0, i64 %indvar7
126 %arrayidx73 = getelementptr [64 x i16]* @sb, i64 0, i64 %indvar7
127 %exitcond9 = icmp ne i64 %indvar7, 64
128 br i1 %exitcond9, label %for.body70, label %for.end84
130 for.body70: ; preds = %for.cond66
131 %tmp74 = load i16* %arrayidx73, align 2
132 %sub76 = sub i16 0, %tmp74
133 store i16 %sub76, i16* %arrayidx80, align 2
136 for.inc81: ; preds = %for.body70
137 %indvar.next8 = add i64 %indvar7, 1
140 for.end84: ; preds = %for.cond66
143 for.cond85: ; preds = %for.inc105, %for.end84
144 %indvar5 = phi i64 [ %indvar.next6, %for.inc105 ], [ 0, %for.end84 ]
145 %arrayidx97 = getelementptr [64 x i16]* @sb, i64 0, i64 %indvar5
146 %arrayidx92 = getelementptr [64 x i16]* @sa, i64 0, i64 %indvar5
147 %i.5 = trunc i64 %indvar5 to i32
148 %cmp87 = icmp slt i32 %i.5, 64
149 br i1 %cmp87, label %for.body89, label %for.end108
151 for.body89: ; preds = %for.cond85
152 %tmp93 = load i16* %arrayidx92, align 2
153 %conv94 = sext i16 %tmp93 to i32
154 %tmp98 = load i16* %arrayidx97, align 2
155 %conv99 = sext i16 %tmp98 to i32
156 %sub100 = sub nsw i32 0, %conv99
157 %cmp101 = icmp eq i32 %conv94, %sub100
158 br i1 %cmp101, label %if.end104, label %if.then103
160 if.then103: ; preds = %for.body89
161 call void @abort() noreturn nounwind
164 if.end104: ; preds = %for.body89
167 for.inc105: ; preds = %if.end104
168 %indvar.next6 = add i64 %indvar5, 1
171 for.end108: ; preds = %for.cond85
172 br label %for.cond109
174 for.cond109: ; preds = %for.inc122, %for.end108
175 %indvar3 = phi i64 [ %indvar.next4, %for.inc122 ], [ 0, %for.end108 ]
176 %arrayidx121 = getelementptr [64 x float]* @fa, i64 0, i64 %indvar3
177 %arrayidx116 = getelementptr [64 x float]* @fb, i64 0, i64 %indvar3
178 %exitcond = icmp ne i64 %indvar3, 64
179 br i1 %exitcond, label %for.body113, label %for.end125
181 for.body113: ; preds = %for.cond109
182 %tmp117 = load float* %arrayidx116, align 4
183 %sub118 = fsub float -0.000000e+00, %tmp117
184 store float %sub118, float* %arrayidx121, align 4
187 for.inc122: ; preds = %for.body113
188 %indvar.next4 = add i64 %indvar3, 1
189 br label %for.cond109
191 for.end125: ; preds = %for.cond109
192 br label %for.cond126
194 for.cond126: ; preds = %for.inc144, %for.end125
195 %indvar = phi i64 [ %indvar.next, %for.inc144 ], [ 0, %for.end125 ]
196 %arrayidx137 = getelementptr [64 x float]* @fb, i64 0, i64 %indvar
197 %arrayidx133 = getelementptr [64 x float]* @fa, i64 0, i64 %indvar
198 %i.7 = trunc i64 %indvar to i32
199 %cmp128 = icmp slt i32 %i.7, 64
200 br i1 %cmp128, label %for.body130, label %for.end147
202 for.body130: ; preds = %for.cond126
203 %tmp134 = load float* %arrayidx133, align 4
204 %tmp138 = load float* %arrayidx137, align 4
205 %sub139 = fsub float -0.000000e+00, %tmp138
206 %cmp140 = fcmp une float %tmp134, %sub139
207 br i1 %cmp140, label %if.then142, label %if.end143
209 if.then142: ; preds = %for.body130
210 call void @abort() noreturn nounwind
213 if.end143: ; preds = %for.body130
216 for.inc144: ; preds = %if.end143
217 %indvar.next = add i64 %indvar, 1
218 br label %for.cond126
220 for.end147: ; preds = %for.cond126
224 declare void @abort() noreturn
226 define i32 @main() nounwind uwtable {
228 call void @check_vect()
229 %call = call i32 @main1()
233 define internal void @check_vect() nounwind uwtable noinline {
235 %a = alloca i32, align 4
236 %b = alloca i32, align 4
237 %c = alloca i32, align 4
238 %d = alloca i32, align 4
239 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
240 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
241 %tobool = icmp eq i32 %call1, 0
242 br i1 %tobool, label %if.then, label %lor.lhs.false
244 lor.lhs.false: ; preds = %entry
245 %tmp4 = load i32* %d, align 4
246 %and6 = and i32 %tmp4, 67108864
247 %cmp = icmp eq i32 %and6, 0
248 br i1 %cmp, label %if.then, label %if.end
250 if.then: ; preds = %entry, %lor.lhs.false
251 call void @exit(i32 0) noreturn nounwind
254 if.end: ; preds = %lor.lhs.false
255 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
259 declare void (i32)* @signal(i32, void (i32)*) nounwind
261 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
263 call void @exit(i32 0) noreturn nounwind
266 return: ; No predecessors!
270 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
272 %and = and i32 %__level, -2147483648
273 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
274 %cmp = icmp ult i32 %call, %__level
275 br i1 %cmp, label %if.then, label %if.end
277 if.then: ; preds = %entry
280 if.end: ; preds = %entry
281 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
282 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
283 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
284 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
285 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
286 store i32 %asmresult, i32* %__eax, align 4
287 store i32 %asmresult8, i32* %__ebx, align 4
288 store i32 %asmresult9, i32* %__ecx, align 4
289 store i32 %asmresult10, i32* %__edx, align 4
292 return: ; preds = %if.end, %if.then
293 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
297 declare void @exit(i32) noreturn
299 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
301 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
302 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
303 %tobool = icmp eq i32* %__sig, null
304 br i1 %tobool, label %if.end, label %if.then
306 if.then: ; preds = %entry
307 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
308 store i32 %asmresult1, i32* %__sig, align 4
311 if.end: ; preds = %entry, %if.then
315 !0 = metadata !{i32 -2147342224, i32 -2147342216}
316 !1 = metadata !{i32 -2147342347, i32 -2147342339}