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-100.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-100.s > vect-100.ll
6 ; ModuleID = 'vect-100.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 @a = internal global [9 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9], align 16
11 @b = internal global [9 x i32] [i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 0], align 16
12 @main2.c = internal unnamed_addr constant [9 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9], align 16
13 @main2.d = internal unnamed_addr constant [9 x i32] [i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 0], align 16
15 define i32 @main1() nounwind uwtable noinline {
17 %call = call noalias i8* @malloc(i64 72) nounwind
20 for.cond: ; preds = %for.inc, %entry
21 %indvar7 = phi i64 [ %indvar.next8, %for.inc ], [ 0, %entry ]
22 %tmp9 = mul i64 %indvar7, 4
23 %tmp11 = add i64 %tmp9, 36
24 %scevgep12 = getelementptr i8* %call, i64 %tmp11
25 %arrayidx14 = bitcast i8* %scevgep12 to i32*
26 %arrayidx9 = getelementptr [9 x i32]* @b, i64 0, i64 %indvar7
27 %scevgep15 = getelementptr i8* %call, i64 %tmp9
28 %arrayidx6 = bitcast i8* %scevgep15 to i32*
29 %arrayidx = getelementptr [9 x i32]* @a, i64 0, i64 %indvar7
30 %exitcond = icmp ne i64 %indvar7, 9
31 br i1 %exitcond, label %for.body, label %for.end
33 for.body: ; preds = %for.cond
34 %tmp2 = load i32* %arrayidx, align 4
35 store i32 %tmp2, i32* %arrayidx6, align 4
36 %tmp10 = load i32* %arrayidx9, align 4
37 store i32 %tmp10, i32* %arrayidx14, align 4
40 for.inc: ; preds = %for.body
41 %indvar.next8 = add i64 %indvar7, 1
44 for.end: ; preds = %for.cond
47 for.cond16: ; preds = %for.inc42, %for.end
48 %indvar = phi i64 [ %indvar.next, %for.inc42 ], [ 0, %for.end ]
49 %arrayidx39 = getelementptr [9 x i32]* @b, i64 0, i64 %indvar
50 %tmp = mul i64 %indvar, 4
51 %tmp1 = add i64 %tmp, 36
52 %scevgep = getelementptr i8* %call, i64 %tmp1
53 %arrayidx35 = bitcast i8* %scevgep to i32*
54 %arrayidx28 = getelementptr [9 x i32]* @a, i64 0, i64 %indvar
55 %scevgep4 = getelementptr i8* %call, i64 %tmp
56 %arrayidx24 = bitcast i8* %scevgep4 to i32*
57 %i.1 = trunc i64 %indvar to i32
58 %cmp18 = icmp slt i32 %i.1, 9
59 br i1 %cmp18, label %for.body19, label %for.end45
61 for.body19: ; preds = %for.cond16
62 %tmp25 = load i32* %arrayidx24, align 4
63 %tmp29 = load i32* %arrayidx28, align 4
64 %cmp30 = icmp eq i32 %tmp25, %tmp29
65 br i1 %cmp30, label %lor.lhs.false, label %if.then
67 lor.lhs.false: ; preds = %for.body19
68 %tmp36 = load i32* %arrayidx35, align 4
69 %tmp40 = load i32* %arrayidx39, align 4
70 %cmp41 = icmp eq i32 %tmp36, %tmp40
71 br i1 %cmp41, label %if.end, label %if.then
73 if.then: ; preds = %lor.lhs.false, %for.body19
74 call void @abort() noreturn nounwind
77 if.end: ; preds = %lor.lhs.false
80 for.inc42: ; preds = %if.end
81 %indvar.next = add i64 %indvar, 1
84 for.end45: ; preds = %for.cond16
88 declare noalias i8* @malloc(i64) nounwind
90 declare void @abort() noreturn nounwind
92 define i32 @main2() nounwind uwtable noinline {
94 %c = alloca [9 x i32], align 16
95 %d = alloca [9 x i32], align 16
96 %tmp = bitcast [9 x i32]* %c to i8*
97 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp, i8* bitcast ([9 x i32]* @main2.c to i8*), i64 36, i32 16, i1 false)
98 %tmp2 = bitcast [9 x i32]* %d to i8*
99 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp2, i8* bitcast ([9 x i32]* @main2.d to i8*), i64 36, i32 16, i1 false)
100 %call = call noalias i8* @malloc(i64 72) nounwind
103 for.cond: ; preds = %for.inc, %entry
104 %indvar9 = phi i64 [ %indvar.next10, %for.inc ], [ 0, %entry ]
105 %tmp11 = mul i64 %indvar9, 4
106 %tmp12 = add i64 %tmp11, 36
107 %scevgep13 = getelementptr i8* %call, i64 %tmp12
108 %arrayidx18 = bitcast i8* %scevgep13 to i32*
109 %arrayidx13 = getelementptr [9 x i32]* %d, i64 0, i64 %indvar9
110 %scevgep16 = getelementptr i8* %call, i64 %tmp11
111 %arrayidx10 = bitcast i8* %scevgep16 to i32*
112 %arrayidx = getelementptr [9 x i32]* %c, i64 0, i64 %indvar9
113 %exitcond = icmp ne i64 %indvar9, 9
114 br i1 %exitcond, label %for.body, label %for.end
116 for.body: ; preds = %for.cond
117 %tmp6 = load i32* %arrayidx, align 4
118 store i32 %tmp6, i32* %arrayidx10, align 4
119 %tmp14 = load i32* %arrayidx13, align 4
120 store i32 %tmp14, i32* %arrayidx18, align 4
123 for.inc: ; preds = %for.body
124 %indvar.next10 = add i64 %indvar9, 1
127 for.end: ; preds = %for.cond
130 for.cond20: ; preds = %for.inc46, %for.end
131 %indvar = phi i64 [ %indvar.next, %for.inc46 ], [ 0, %for.end ]
132 %arrayidx43 = getelementptr [9 x i32]* %d, i64 0, i64 %indvar
133 %tmp1 = mul i64 %indvar, 4
134 %tmp3 = add i64 %tmp1, 36
135 %scevgep = getelementptr i8* %call, i64 %tmp3
136 %arrayidx39 = bitcast i8* %scevgep to i32*
137 %arrayidx32 = getelementptr [9 x i32]* %c, i64 0, i64 %indvar
138 %scevgep6 = getelementptr i8* %call, i64 %tmp1
139 %arrayidx28 = bitcast i8* %scevgep6 to i32*
140 %i.1 = trunc i64 %indvar to i32
141 %cmp22 = icmp slt i32 %i.1, 9
142 br i1 %cmp22, label %for.body23, label %for.end49
144 for.body23: ; preds = %for.cond20
145 %tmp29 = load i32* %arrayidx28, align 4
146 %tmp33 = load i32* %arrayidx32, align 4
147 %cmp34 = icmp eq i32 %tmp29, %tmp33
148 br i1 %cmp34, label %lor.lhs.false, label %if.then
150 lor.lhs.false: ; preds = %for.body23
151 %tmp40 = load i32* %arrayidx39, align 4
152 %tmp44 = load i32* %arrayidx43, align 4
153 %cmp45 = icmp eq i32 %tmp40, %tmp44
154 br i1 %cmp45, label %if.end, label %if.then
156 if.then: ; preds = %lor.lhs.false, %for.body23
157 call void @abort() noreturn nounwind
160 if.end: ; preds = %lor.lhs.false
163 for.inc46: ; preds = %if.end
164 %indvar.next = add i64 %indvar, 1
167 for.end49: ; preds = %for.cond20
171 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
173 define i32 @main() nounwind uwtable {
175 call void @check_vect()
176 %call = call i32 @main1()
177 %call1 = call i32 @main2()
181 define internal void @check_vect() nounwind uwtable noinline {
183 %a = alloca i32, align 4
184 %b = alloca i32, align 4
185 %c = alloca i32, align 4
186 %d = alloca i32, align 4
187 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
188 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
189 %tobool = icmp eq i32 %call1, 0
190 br i1 %tobool, label %if.then, label %lor.lhs.false
192 lor.lhs.false: ; preds = %entry
193 %tmp4 = load i32* %d, align 4
194 %and6 = and i32 %tmp4, 67108864
195 %cmp = icmp eq i32 %and6, 0
196 br i1 %cmp, label %if.then, label %if.end
198 if.then: ; preds = %entry, %lor.lhs.false
199 call void @exit(i32 0) noreturn nounwind
202 if.end: ; preds = %lor.lhs.false
203 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
207 declare void (i32)* @signal(i32, void (i32)*) nounwind
209 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
211 call void @exit(i32 0) noreturn nounwind
214 return: ; No predecessors!
218 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
220 %and = and i32 %__level, -2147483648
221 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
222 %cmp = icmp ult i32 %call, %__level
223 br i1 %cmp, label %if.then, label %if.end
225 if.then: ; preds = %entry
228 if.end: ; preds = %entry
229 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
230 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
231 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
232 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
233 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
234 store i32 %asmresult, i32* %__eax, align 4
235 store i32 %asmresult8, i32* %__ebx, align 4
236 store i32 %asmresult9, i32* %__ecx, align 4
237 store i32 %asmresult10, i32* %__edx, align 4
240 return: ; preds = %if.end, %if.then
241 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
245 declare void @exit(i32) noreturn nounwind
247 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
249 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
250 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
251 %tobool = icmp eq i32* %__sig, null
252 br i1 %tobool, label %if.end, label %if.then
254 if.then: ; preds = %entry
255 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
256 store i32 %asmresult1, i32* %__sig, align 4
259 if.end: ; preds = %entry, %if.then
263 !0 = metadata !{i32 -2147225728, i32 -2147225720}
264 !1 = metadata !{i32 -2147225851, i32 -2147225843}