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-21.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-21.s > vect-21.ll
6 ; ModuleID = 'vect-21.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 @ic = 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
12 @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
13 @cc = 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
14 @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
15 @sc = 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
16 @ia = common global [64 x i32] zeroinitializer, align 16
17 @ca = common global [64 x i8] zeroinitializer, align 16
18 @sa = common global [64 x i16] zeroinitializer, align 16
20 define i32 @main1() nounwind uwtable noinline {
24 for.cond: ; preds = %for.inc, %entry
25 %indvar10 = phi i64 [ %indvar.next11, %for.inc ], [ 0, %entry ]
26 %arrayidx5 = getelementptr [64 x i32]* @ia, i64 0, i64 %indvar10
27 %arrayidx = getelementptr [64 x i32]* @ib, i64 0, i64 %indvar10
28 %exitcond12 = icmp ne i64 %indvar10, 64
29 br i1 %exitcond12, label %for.body, label %for.end
31 for.body: ; preds = %for.cond
32 %tmp2 = load i32* %arrayidx, align 4
33 %lnot = icmp eq i32 %tmp2, 0
34 %lnot.ext = zext i1 %lnot to i32
35 store i32 %lnot.ext, i32* %arrayidx5, align 4
38 for.inc: ; preds = %for.body
39 %indvar.next11 = add i64 %indvar10, 1
42 for.end: ; preds = %for.cond
45 for.cond7: ; preds = %for.inc23, %for.end
46 %indvar8 = phi i64 [ %indvar.next9, %for.inc23 ], [ 0, %for.end ]
47 %arrayidx17 = getelementptr [64 x i32]* @ib, i64 0, i64 %indvar8
48 %arrayidx13 = getelementptr [64 x i32]* @ia, i64 0, i64 %indvar8
49 %i.1 = trunc i64 %indvar8 to i32
50 %cmp9 = icmp slt i32 %i.1, 64
51 br i1 %cmp9, label %for.body10, label %for.end26
53 for.body10: ; preds = %for.cond7
54 %tmp14 = load i32* %arrayidx13, align 4
55 %tmp18 = load i32* %arrayidx17, align 4
56 %lnot20 = icmp eq i32 %tmp18, 0
57 %lnot.ext21 = zext i1 %lnot20 to i32
58 %cmp22 = icmp eq i32 %tmp14, %lnot.ext21
59 br i1 %cmp22, label %if.end, label %if.then
61 if.then: ; preds = %for.body10
62 call void @abort() noreturn nounwind
65 if.end: ; preds = %for.body10
68 for.inc23: ; preds = %if.end
69 %indvar.next9 = add i64 %indvar8, 1
72 for.end26: ; preds = %for.cond7
75 for.cond27: ; preds = %for.inc41, %for.end26
76 %indvar5 = phi i64 [ %indvar.next6, %for.inc41 ], [ 0, %for.end26 ]
77 %arrayidx40 = getelementptr [64 x i8]* @ca, i64 0, i64 %indvar5
78 %arrayidx33 = getelementptr [64 x i8]* @cb, i64 0, i64 %indvar5
79 %exitcond7 = icmp ne i64 %indvar5, 64
80 br i1 %exitcond7, label %for.body30, label %for.end44
82 for.body30: ; preds = %for.cond27
83 %tmp34 = load i8* %arrayidx33, align 1
84 %lnot36 = icmp eq i8 %tmp34, 0
85 %conv = zext i1 %lnot36 to i8
86 store i8 %conv, i8* %arrayidx40, align 1
89 for.inc41: ; preds = %for.body30
90 %indvar.next6 = add i64 %indvar5, 1
93 for.end44: ; preds = %for.cond27
96 for.cond45: ; preds = %for.inc66, %for.end44
97 %indvar3 = phi i64 [ %indvar.next4, %for.inc66 ], [ 0, %for.end44 ]
98 %arrayidx57 = getelementptr [64 x i8]* @cb, i64 0, i64 %indvar3
99 %arrayidx52 = getelementptr [64 x i8]* @ca, i64 0, i64 %indvar3
100 %i.3 = trunc i64 %indvar3 to i32
101 %cmp47 = icmp slt i32 %i.3, 64
102 br i1 %cmp47, label %for.body49, label %for.end69
104 for.body49: ; preds = %for.cond45
105 %tmp53 = load i8* %arrayidx52, align 1
106 %conv54 = sext i8 %tmp53 to i32
107 %tmp58 = load i8* %arrayidx57, align 1
108 %lnot60 = icmp eq i8 %tmp58, 0
109 %lnot.ext61 = zext i1 %lnot60 to i32
110 %cmp62 = icmp eq i32 %conv54, %lnot.ext61
111 br i1 %cmp62, label %if.end65, label %if.then64
113 if.then64: ; preds = %for.body49
114 call void @abort() noreturn nounwind
117 if.end65: ; preds = %for.body49
120 for.inc66: ; preds = %if.end65
121 %indvar.next4 = add i64 %indvar3, 1
124 for.end69: ; preds = %for.cond45
127 for.cond70: ; preds = %for.inc86, %for.end69
128 %indvar1 = phi i64 [ %indvar.next2, %for.inc86 ], [ 0, %for.end69 ]
129 %arrayidx85 = getelementptr [64 x i16]* @sa, i64 0, i64 %indvar1
130 %arrayidx77 = getelementptr [64 x i16]* @sb, i64 0, i64 %indvar1
131 %exitcond = icmp ne i64 %indvar1, 64
132 br i1 %exitcond, label %for.body74, label %for.end89
134 for.body74: ; preds = %for.cond70
135 %tmp78 = load i16* %arrayidx77, align 2
136 %lnot80 = icmp eq i16 %tmp78, 0
137 %conv82 = zext i1 %lnot80 to i16
138 store i16 %conv82, i16* %arrayidx85, align 2
141 for.inc86: ; preds = %for.body74
142 %indvar.next2 = add i64 %indvar1, 1
145 for.end89: ; preds = %for.cond70
148 for.cond90: ; preds = %for.inc111, %for.end89
149 %indvar = phi i64 [ %indvar.next, %for.inc111 ], [ 0, %for.end89 ]
150 %arrayidx102 = getelementptr [64 x i16]* @sb, i64 0, i64 %indvar
151 %arrayidx97 = getelementptr [64 x i16]* @sa, i64 0, i64 %indvar
152 %i.5 = trunc i64 %indvar to i32
153 %cmp92 = icmp slt i32 %i.5, 64
154 br i1 %cmp92, label %for.body94, label %for.end114
156 for.body94: ; preds = %for.cond90
157 %tmp98 = load i16* %arrayidx97, align 2
158 %conv99 = sext i16 %tmp98 to i32
159 %tmp103 = load i16* %arrayidx102, align 2
160 %lnot105 = icmp eq i16 %tmp103, 0
161 %lnot.ext106 = zext i1 %lnot105 to i32
162 %cmp107 = icmp eq i32 %conv99, %lnot.ext106
163 br i1 %cmp107, label %if.end110, label %if.then109
165 if.then109: ; preds = %for.body94
166 call void @abort() noreturn nounwind
169 if.end110: ; preds = %for.body94
172 for.inc111: ; preds = %if.end110
173 %indvar.next = add i64 %indvar, 1
176 for.end114: ; preds = %for.cond90
180 declare void @abort() noreturn
182 define i32 @main() nounwind uwtable {
184 call void @check_vect()
185 %call = call i32 @main1()
189 define internal void @check_vect() nounwind uwtable noinline {
191 %a = alloca i32, align 4
192 %b = alloca i32, align 4
193 %c = alloca i32, align 4
194 %d = alloca i32, align 4
195 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
196 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
197 %tobool = icmp eq i32 %call1, 0
198 br i1 %tobool, label %if.then, label %lor.lhs.false
200 lor.lhs.false: ; preds = %entry
201 %tmp4 = load i32* %d, align 4
202 %and6 = and i32 %tmp4, 67108864
203 %cmp = icmp eq i32 %and6, 0
204 br i1 %cmp, label %if.then, label %if.end
206 if.then: ; preds = %entry, %lor.lhs.false
207 call void @exit(i32 0) noreturn nounwind
210 if.end: ; preds = %lor.lhs.false
211 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
215 declare void (i32)* @signal(i32, void (i32)*) nounwind
217 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
219 call void @exit(i32 0) noreturn nounwind
222 return: ; No predecessors!
226 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
228 %and = and i32 %__level, -2147483648
229 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
230 %cmp = icmp ult i32 %call, %__level
231 br i1 %cmp, label %if.then, label %if.end
233 if.then: ; preds = %entry
236 if.end: ; preds = %entry
237 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
238 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
239 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
240 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
241 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
242 store i32 %asmresult, i32* %__eax, align 4
243 store i32 %asmresult8, i32* %__ebx, align 4
244 store i32 %asmresult9, i32* %__ecx, align 4
245 store i32 %asmresult10, i32* %__edx, align 4
248 return: ; preds = %if.end, %if.then
249 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
253 declare void @exit(i32) noreturn
255 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
257 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
258 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
259 %tobool = icmp eq i32* %__sig, null
260 br i1 %tobool, label %if.end, label %if.then
262 if.then: ; preds = %entry
263 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
264 store i32 %asmresult1, i32* %__sig, align 4
267 if.end: ; preds = %entry, %if.then
271 !0 = metadata !{i32 -2147342094, i32 -2147342086}
272 !1 = metadata !{i32 -2147342217, i32 -2147342209}