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-multitypes-4.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-multitypes-4.s > vect-multitypes-4.ll
6 ; ModuleID = 'vect-multitypes-4.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 @sc = global [32 x i16] [i16 0, i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7, i16 8, i16 9, i16 10, i16 11, i16 12, i16 13, i16 14, i16 15, i16 16, i16 17, i16 18, i16 19, i16 20, i16 21, i16 22, i16 23, i16 24, i16 25, i16 26, i16 27, i16 28, i16 29, i16 30, i16 31], align 16
11 @sb = global [32 x i16] [i16 0, i16 1, i16 2, i16 3, i16 4, i16 5, i16 6, i16 7, i16 8, i16 9, i16 10, i16 11, i16 12, i16 13, i16 14, i16 15, i16 16, i16 17, i16 18, i16 19, i16 20, i16 21, i16 22, i16 23, i16 24, i16 25, i16 26, i16 27, i16 28, i16 29, i16 30, i16 31], align 16
12 @ic = global [32 x i32] [i32 0, i32 3, i32 6, i32 9, i32 12, i32 15, i32 18, i32 21, i32 24, i32 27, i32 30, i32 33, i32 36, i32 39, i32 42, i32 45, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15], align 16
13 @ib = global [32 x i32] [i32 0, i32 3, i32 6, i32 9, i32 12, i32 15, i32 18, i32 21, i32 24, i32 27, i32 30, i32 33, i32 36, i32 39, i32 42, i32 45, i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15], align 16
14 @sa = common global [32 x i16] zeroinitializer, align 16
15 @ia = common global [32 x i32] zeroinitializer, align 16
17 define i32 @main1(i32 %n) nounwind uwtable noinline {
19 %tmp8 = icmp sgt i32 %n, 0
20 %smax = select i1 %tmp8, i32 %n, i32 0
21 %tmp9 = zext i32 %smax to i64
24 for.cond: ; preds = %for.inc, %entry
25 %indvar6 = phi i64 [ %indvar.next7, %for.inc ], [ 0, %entry ]
26 %tmp10 = add i64 %indvar6, 3
27 %add24 = trunc i64 %tmp10 to i32
28 %arrayidx20 = getelementptr [32 x i32]* @ic, i64 0, i64 %indvar6
29 %arrayidx16 = getelementptr [32 x i32]* @ib, i64 0, i64 %indvar6
30 %tmp12 = add i64 %indvar6, 7
31 %add11 = trunc i64 %tmp12 to i32
32 %arrayidx6 = getelementptr [32 x i16]* @sc, i64 0, i64 %indvar6
33 %arrayidx = getelementptr [32 x i16]* @sb, i64 0, i64 %indvar6
34 %exitcond = icmp ne i64 %indvar6, %tmp9
35 br i1 %exitcond, label %for.body, label %for.end
37 for.body: ; preds = %for.cond
38 %tmp3 = load i16* %arrayidx, align 2
39 %tmp7 = load i16* %arrayidx6, align 2
40 %add = add i16 %tmp3, %tmp7
41 %idxprom12 = sext i32 %add11 to i64
42 %arrayidx13 = getelementptr inbounds [32 x i16]* @sa, i64 0, i64 %idxprom12
43 store i16 %add, i16* %arrayidx13, align 2
44 %tmp17 = load i32* %arrayidx16, align 4
45 %tmp21 = load i32* %arrayidx20, align 4
46 %add22 = add i32 %tmp17, %tmp21
47 %idxprom25 = sext i32 %add24 to i64
48 %arrayidx26 = getelementptr inbounds [32 x i32]* @ia, i64 0, i64 %idxprom25
49 store i32 %add22, i32* %arrayidx26, align 4
52 for.inc: ; preds = %for.body
53 %indvar.next7 = add i64 %indvar6, 1
56 for.end: ; preds = %for.cond
59 for.cond28: ; preds = %for.inc69, %for.end
60 %indvar = phi i64 [ %indvar.next, %for.inc69 ], [ 0, %for.end ]
61 %arrayidx64 = getelementptr [32 x i32]* @ic, i64 0, i64 %indvar
62 %arrayidx60 = getelementptr [32 x i32]* @ib, i64 0, i64 %indvar
63 %tmp = add i64 %indvar, 3
64 %add54 = trunc i64 %tmp to i32
65 %arrayidx47 = getelementptr [32 x i16]* @sc, i64 0, i64 %indvar
66 %arrayidx42 = getelementptr [32 x i16]* @sb, i64 0, i64 %indvar
67 %tmp2 = add i64 %indvar, 7
68 %add35 = trunc i64 %tmp2 to i32
69 %i.1 = trunc i64 %indvar to i32
70 %cmp31 = icmp slt i32 %i.1, %n
71 br i1 %cmp31, label %for.body33, label %for.end72
73 for.body33: ; preds = %for.cond28
74 %idxprom36 = sext i32 %add35 to i64
75 %arrayidx37 = getelementptr inbounds [32 x i16]* @sa, i64 0, i64 %idxprom36
76 %tmp38 = load i16* %arrayidx37, align 2
77 %conv39 = zext i16 %tmp38 to i32
78 %tmp43 = load i16* %arrayidx42, align 2
79 %conv44 = zext i16 %tmp43 to i32
80 %tmp48 = load i16* %arrayidx47, align 2
81 %conv49 = zext i16 %tmp48 to i32
82 %add50 = add nsw i32 %conv44, %conv49
83 %cmp51 = icmp eq i32 %conv39, %add50
84 br i1 %cmp51, label %lor.lhs.false, label %if.then
86 lor.lhs.false: ; preds = %for.body33
87 %idxprom55 = sext i32 %add54 to i64
88 %arrayidx56 = getelementptr inbounds [32 x i32]* @ia, i64 0, i64 %idxprom55
89 %tmp57 = load i32* %arrayidx56, align 4
90 %tmp61 = load i32* %arrayidx60, align 4
91 %tmp65 = load i32* %arrayidx64, align 4
92 %add66 = add i32 %tmp61, %tmp65
93 %cmp67 = icmp eq i32 %tmp57, %add66
94 br i1 %cmp67, label %if.end, label %if.then
96 if.then: ; preds = %lor.lhs.false, %for.body33
97 call void @abort() noreturn nounwind
100 if.end: ; preds = %lor.lhs.false
103 for.inc69: ; preds = %if.end
104 %indvar.next = add i64 %indvar, 1
107 for.end72: ; preds = %for.cond28
111 declare void @abort() noreturn
113 define i32 @main2(i32 %n) nounwind uwtable noinline {
115 %tmp5 = icmp sgt i32 %n, 0
116 %smax = select i1 %tmp5, i32 %n, i32 0
117 %tmp6 = zext i32 %smax to i64
120 for.cond: ; preds = %for.inc, %entry
121 %indvar3 = phi i64 [ %indvar.next4, %for.inc ], [ 0, %entry ]
122 %tmp8 = add i64 %indvar3, 3
123 %add9 = trunc i64 %tmp8 to i32
124 %arrayidx18 = getelementptr [32 x i16]* @sc, i64 0, i64 %indvar3
125 %arrayidx14 = getelementptr [32 x i16]* @sb, i64 0, i64 %indvar3
126 %arrayidx6 = getelementptr [32 x i32]* @ic, i64 0, i64 %indvar3
127 %arrayidx = getelementptr [32 x i32]* @ib, i64 0, i64 %indvar3
128 %exitcond = icmp ne i64 %indvar3, %tmp6
129 br i1 %exitcond, label %for.body, label %for.end
131 for.body: ; preds = %for.cond
132 %tmp3 = load i32* %arrayidx, align 4
133 %tmp7 = load i32* %arrayidx6, align 4
134 %add = add i32 %tmp3, %tmp7
135 %idxprom10 = sext i32 %add9 to i64
136 %arrayidx11 = getelementptr inbounds [32 x i32]* @ia, i64 0, i64 %idxprom10
137 store i32 %add, i32* %arrayidx11, align 4
138 %tmp15 = load i16* %arrayidx14, align 2
139 %tmp19 = load i16* %arrayidx18, align 2
140 %add21 = add i16 %tmp15, %tmp19
141 %idxprom25 = sext i32 %add9 to i64
142 %arrayidx26 = getelementptr inbounds [32 x i16]* @sa, i64 0, i64 %idxprom25
143 store i16 %add21, i16* %arrayidx26, align 2
146 for.inc: ; preds = %for.body
147 %indvar.next4 = add i64 %indvar3, 1
150 for.end: ; preds = %for.cond
153 for.cond28: ; preds = %for.inc69, %for.end
154 %indvar = phi i64 [ %indvar.next, %for.inc69 ], [ 0, %for.end ]
155 %arrayidx64 = getelementptr [32 x i32]* @ic, i64 0, i64 %indvar
156 %arrayidx60 = getelementptr [32 x i32]* @ib, i64 0, i64 %indvar
157 %tmp = add i64 %indvar, 3
158 %add35 = trunc i64 %tmp to i32
159 %arrayidx47 = getelementptr [32 x i16]* @sc, i64 0, i64 %indvar
160 %arrayidx42 = getelementptr [32 x i16]* @sb, i64 0, i64 %indvar
161 %i.1 = trunc i64 %indvar to i32
162 %cmp31 = icmp slt i32 %i.1, %n
163 br i1 %cmp31, label %for.body33, label %for.end72
165 for.body33: ; preds = %for.cond28
166 %idxprom36 = sext i32 %add35 to i64
167 %arrayidx37 = getelementptr inbounds [32 x i16]* @sa, i64 0, i64 %idxprom36
168 %tmp38 = load i16* %arrayidx37, align 2
169 %conv39 = zext i16 %tmp38 to i32
170 %tmp43 = load i16* %arrayidx42, align 2
171 %conv44 = zext i16 %tmp43 to i32
172 %tmp48 = load i16* %arrayidx47, align 2
173 %conv49 = zext i16 %tmp48 to i32
174 %add50 = add nsw i32 %conv44, %conv49
175 %cmp51 = icmp eq i32 %conv39, %add50
176 br i1 %cmp51, label %lor.lhs.false, label %if.then
178 lor.lhs.false: ; preds = %for.body33
179 %idxprom55 = sext i32 %add35 to i64
180 %arrayidx56 = getelementptr inbounds [32 x i32]* @ia, i64 0, i64 %idxprom55
181 %tmp57 = load i32* %arrayidx56, align 4
182 %tmp61 = load i32* %arrayidx60, align 4
183 %tmp65 = load i32* %arrayidx64, align 4
184 %add66 = add i32 %tmp61, %tmp65
185 %cmp67 = icmp eq i32 %tmp57, %add66
186 br i1 %cmp67, label %if.end, label %if.then
188 if.then: ; preds = %lor.lhs.false, %for.body33
189 call void @abort() noreturn nounwind
192 if.end: ; preds = %lor.lhs.false
195 for.inc69: ; preds = %if.end
196 %indvar.next = add i64 %indvar, 1
199 for.end72: ; preds = %for.cond28
203 define i32 @main() nounwind uwtable {
205 call void @check_vect()
206 %call = call i32 @main1(i32 25)
207 %call1 = call i32 @main2(i32 29)
211 define internal void @check_vect() nounwind uwtable noinline {
213 %a = alloca i32, align 4
214 %b = alloca i32, align 4
215 %c = alloca i32, align 4
216 %d = alloca i32, align 4
217 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
218 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
219 %tobool = icmp eq i32 %call1, 0
220 br i1 %tobool, label %if.then, label %lor.lhs.false
222 lor.lhs.false: ; preds = %entry
223 %tmp4 = load i32* %d, align 4
224 %and6 = and i32 %tmp4, 67108864
225 %cmp = icmp eq i32 %and6, 0
226 br i1 %cmp, label %if.then, label %if.end
228 if.then: ; preds = %entry, %lor.lhs.false
229 call void @exit(i32 0) noreturn nounwind
232 if.end: ; preds = %lor.lhs.false
233 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
237 declare void (i32)* @signal(i32, void (i32)*) nounwind
239 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
241 call void @exit(i32 0) noreturn nounwind
244 return: ; No predecessors!
248 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
250 %and = and i32 %__level, -2147483648
251 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
252 %cmp = icmp ult i32 %call, %__level
253 br i1 %cmp, label %if.then, label %if.end
255 if.then: ; preds = %entry
258 if.end: ; preds = %entry
259 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
260 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
261 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
262 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
263 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
264 store i32 %asmresult, i32* %__eax, align 4
265 store i32 %asmresult8, i32* %__ebx, align 4
266 store i32 %asmresult9, i32* %__ecx, align 4
267 store i32 %asmresult10, i32* %__edx, align 4
270 return: ; preds = %if.end, %if.then
271 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
275 declare void @exit(i32) noreturn
277 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
279 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
280 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
281 %tobool = icmp eq i32* %__sig, null
282 br i1 %tobool, label %if.end, label %if.then
284 if.then: ; preds = %entry
285 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
286 store i32 %asmresult1, i32* %__sig, align 4
289 if.end: ; preds = %entry, %if.then
293 !0 = metadata !{i32 -2147340927, i32 -2147340919}
294 !1 = metadata !{i32 -2147341050, i32 -2147341042}