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-4l.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-outer-4l.s > vect-outer-4l.ll
6 ; ModuleID = 'vect-outer-4l.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 @arr = common global [96 x i8] zeroinitializer, align 16
11 @in = common global [224 x i16] zeroinitializer, align 16
12 @out = common global [96 x i32] zeroinitializer, align 16
14 define i32 @foo() nounwind uwtable noinline {
18 for.cond: ; preds = %for.inc18, %entry
19 %indvar1 = phi i64 [ %indvar.next2, %for.inc18 ], [ 0, %entry ]
20 %s.0 = phi i32 [ 0, %entry ], [ %add17, %for.inc18 ]
21 %arrayidx = getelementptr [96 x i8]* @arr, i64 0, i64 %indvar1
22 %exitcond5 = icmp ne i64 %indvar1, 96
23 br i1 %exitcond5, label %for.body, label %for.end20
25 for.body: ; preds = %for.cond
26 store i8 3, i8* %arrayidx, align 1
29 for.cond2: ; preds = %for.inc, %for.body
30 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %for.body ]
31 %diff.0 = phi i32 [ 0, %for.body ], [ %add12, %for.inc ]
32 %tmp6 = mul i64 %indvar, 8
33 %tmp7 = add i64 %indvar1, %tmp6
34 %arrayidx9 = getelementptr [224 x i16]* @in, i64 0, i64 %tmp7
35 %exitcond = icmp ne i64 %indvar, 16
36 br i1 %exitcond, label %for.body5, label %for.end
38 for.body5: ; preds = %for.cond2
41 for.inc: ; preds = %for.body5
42 %tmp10 = load i16* %arrayidx9, align 2
43 %conv = zext i16 %tmp10 to i32
44 %add12 = add i32 %diff.0, %conv
45 %indvar.next = add i64 %indvar, 1
48 for.end: ; preds = %for.cond2
49 %diff.0.lcssa = phi i32 [ %diff.0, %for.cond2 ]
52 for.inc18: ; preds = %for.end
53 %add17 = add i32 %s.0, %diff.0.lcssa
54 %indvar.next2 = add i64 %indvar1, 1
57 for.end20: ; preds = %for.cond
58 %s.0.lcssa = phi i32 [ %s.0, %for.cond ]
62 define i32 @bar(i32 %i, i32 %diff, i16* %in) nounwind uwtable noinline {
66 for.cond: ; preds = %for.inc, %entry
67 %indvar = phi i32 [ %indvar.next, %for.inc ], [ 0, %entry ]
68 %diff.addr.0 = phi i32 [ %diff, %entry ], [ %add6, %for.inc ]
69 %j.0 = mul i32 %indvar, 8
70 %add = add i32 %i, %j.0
71 %exitcond = icmp ne i32 %indvar, 16
72 br i1 %exitcond, label %for.body, label %for.end
74 for.body: ; preds = %for.cond
77 for.inc: ; preds = %for.body
78 %idxprom = sext i32 %add to i64
79 %arrayidx = getelementptr inbounds i16* %in, i64 %idxprom
80 %tmp4 = load i16* %arrayidx, align 2
81 %conv = zext i16 %tmp4 to i32
82 %add6 = add i32 %diff.addr.0, %conv
83 %indvar.next = add i32 %indvar, 1
86 for.end: ; preds = %for.cond
87 %diff.addr.0.lcssa = phi i32 [ %diff.addr.0, %for.cond ]
88 ret i32 %diff.addr.0.lcssa
91 define i32 @main() nounwind uwtable {
93 call void @check_vect()
96 for.cond: ; preds = %for.inc, %entry
97 %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %entry ]
98 %arrayidx = getelementptr [224 x i16]* @in, i64 0, i64 %indvar1
99 %conv = trunc i64 %indvar1 to i16
100 %exitcond3 = icmp ne i64 %indvar1, 224
101 br i1 %exitcond3, label %for.body, label %for.end
103 for.body: ; preds = %for.cond
104 store i16 %conv, i16* %arrayidx, align 2
107 for.inc: ; preds = %for.body
108 %indvar.next2 = add i64 %indvar1, 1
111 for.end: ; preds = %for.cond
112 %call = call i32 @foo()
115 for.cond4: ; preds = %for.inc17, %for.end
116 %indvar = phi i64 [ %indvar.next, %for.inc17 ], [ 0, %for.end ]
117 %s.0 = phi i32 [ 0, %for.end ], [ %add, %for.inc17 ]
118 %i.1 = trunc i64 %indvar to i32
119 %arrayidx11 = getelementptr [96 x i8]* @arr, i64 0, i64 %indvar
120 %exitcond = icmp ne i64 %indvar, 96
121 br i1 %exitcond, label %for.body8, label %for.end20
123 for.body8: ; preds = %for.cond4
124 store i8 3, i8* %arrayidx11, align 1
125 %call14 = call i32 @bar(i32 %i.1, i32 0, i16* getelementptr inbounds ([224 x i16]* @in, i64 0, i64 0))
128 for.inc17: ; preds = %for.body8
129 %add = add i32 %s.0, %call14
130 %indvar.next = add i64 %indvar, 1
133 for.end20: ; preds = %for.cond4
134 %s.0.lcssa = phi i32 [ %s.0, %for.cond4 ]
135 %cmp23 = icmp eq i32 %s.0.lcssa, %call
136 br i1 %cmp23, label %if.end, label %if.then
138 if.then: ; preds = %for.end20
139 call void @abort() noreturn nounwind
142 if.end: ; preds = %for.end20
146 define internal void @check_vect() nounwind uwtable noinline {
148 %a = alloca i32, align 4
149 %b = alloca i32, align 4
150 %c = alloca i32, align 4
151 %d = alloca i32, align 4
152 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
153 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
154 %tobool = icmp eq i32 %call1, 0
155 br i1 %tobool, label %if.then, label %lor.lhs.false
157 lor.lhs.false: ; preds = %entry
158 %tmp4 = load i32* %d, align 4
159 %and6 = and i32 %tmp4, 67108864
160 %cmp = icmp eq i32 %and6, 0
161 br i1 %cmp, label %if.then, label %if.end
163 if.then: ; preds = %entry, %lor.lhs.false
164 call void @exit(i32 0) noreturn nounwind
167 if.end: ; preds = %lor.lhs.false
168 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
172 declare void @abort() noreturn
174 declare void (i32)* @signal(i32, void (i32)*) nounwind
176 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
178 call void @exit(i32 0) noreturn nounwind
181 return: ; No predecessors!
185 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
187 %and = and i32 %__level, -2147483648
188 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
189 %cmp = icmp ult i32 %call, %__level
190 br i1 %cmp, label %if.then, label %if.end
192 if.then: ; preds = %entry
195 if.end: ; preds = %entry
196 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
197 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
198 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
199 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
200 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
201 store i32 %asmresult, i32* %__eax, align 4
202 store i32 %asmresult8, i32* %__ebx, align 4
203 store i32 %asmresult9, i32* %__ecx, align 4
204 store i32 %asmresult10, i32* %__edx, align 4
207 return: ; preds = %if.end, %if.then
208 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
212 declare void @exit(i32) noreturn
214 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
216 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
217 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
218 %tobool = icmp eq i32* %__sig, null
219 br i1 %tobool, label %if.end, label %if.then
221 if.then: ; preds = %entry
222 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
223 store i32 %asmresult1, i32* %__sig, align 4
226 if.end: ; preds = %entry, %if.then
230 !0 = metadata !{i32 -2147343149, i32 -2147343141}
231 !1 = metadata !{i32 -2147343272, i32 -2147343264}