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 pr37539.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer pr37539.s > pr37539.ll
6 ; ModuleID = 'pr37539.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 define void @ayuv2yuyv_ref(i32* %d, i32* %src, i32 %n) nounwind uwtable noinline {
12 %tmp = bitcast i32* %d to i8*
15 for.cond: ; preds = %for.inc, %entry
16 %tmp22 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
17 %mul8 = mul i32 %tmp22, 4
18 %add5411 = add i32 %mul8, 3
19 %mul = mul i32 %tmp22, 2
20 %add3910 = add i32 %mul8, 2
21 %add248 = add i32 %mul8, 1
22 %add156 = add i32 %mul, 1
24 %cmp = icmp slt i32 %tmp22, %div
25 br i1 %cmp, label %for.body, label %for.end
27 for.body: ; preds = %for.cond
28 %idxprom = sext i32 %mul to i64
29 %arrayidx = getelementptr inbounds i32* %src, i64 %idxprom
30 %tmp6 = load i32* %arrayidx, align 4
31 %shr5 = lshr i32 %tmp6, 16
32 %conv = trunc i32 %shr5 to i8
33 %idxprom10 = sext i32 %mul8 to i64
34 %arrayidx12 = getelementptr inbounds i8* %tmp, i64 %idxprom10
35 store i8 %conv, i8* %arrayidx12, align 1
36 %idxprom16 = sext i32 %add156 to i64
37 %arrayidx18 = getelementptr inbounds i32* %src, i64 %idxprom16
38 %tmp19 = load i32* %arrayidx18, align 4
39 %shr207 = lshr i32 %tmp19, 8
40 %conv21 = trunc i32 %shr207 to i8
41 %idxprom25 = sext i32 %add248 to i64
42 %arrayidx27 = getelementptr inbounds i8* %tmp, i64 %idxprom25
43 store i8 %conv21, i8* %arrayidx27, align 1
44 %idxprom31 = sext i32 %mul to i64
45 %arrayidx33 = getelementptr inbounds i32* %src, i64 %idxprom31
46 %tmp34 = load i32* %arrayidx33, align 4
47 %shr359 = lshr i32 %tmp34, 16
48 %conv36 = trunc i32 %shr359 to i8
49 %idxprom40 = sext i32 %add3910 to i64
50 %arrayidx42 = getelementptr inbounds i8* %tmp, i64 %idxprom40
51 store i8 %conv36, i8* %arrayidx42, align 1
52 %idxprom46 = sext i32 %mul to i64
53 %arrayidx48 = getelementptr inbounds i32* %src, i64 %idxprom46
54 %tmp49 = load i32* %arrayidx48, align 4
55 %conv51 = trunc i32 %tmp49 to i8
56 %idxprom55 = sext i32 %add5411 to i64
57 %arrayidx57 = getelementptr inbounds i8* %tmp, i64 %idxprom55
58 store i8 %conv51, i8* %arrayidx57, align 1
61 for.inc: ; preds = %for.body
62 %inc = add nsw i32 %tmp22, 1
65 for.end: ; preds = %for.cond
68 for.cond59: ; preds = %for.inc140, %for.end
69 %tmp23 = phi i32 [ 0, %for.end ], [ %inc142, %for.inc140 ]
70 %mul75 = mul i32 %tmp23, 2
71 %mul67 = mul i32 %tmp23, 4
72 %add1244 = add i32 %mul67, 3
73 %add1053 = add i32 %mul67, 2
74 %add942 = add i32 %mul75, 1
75 %add861 = add i32 %mul67, 1
76 %div62 = sdiv i32 %n, 2
77 %cmp63 = icmp slt i32 %tmp23, %div62
78 br i1 %cmp63, label %for.body65, label %for.end143
80 for.body65: ; preds = %for.cond59
81 %idxprom69 = sext i32 %mul67 to i64
82 %arrayidx71 = getelementptr inbounds i8* %tmp, i64 %idxprom69
83 %tmp72 = load i8* %arrayidx71, align 1
84 %conv73 = sext i8 %tmp72 to i32
85 %idxprom77 = sext i32 %mul75 to i64
86 %arrayidx79 = getelementptr inbounds i32* %src, i64 %idxprom77
87 %tmp80 = load i32* %arrayidx79, align 4
88 %shr81 = ashr i32 %tmp80, 16
89 %cmp82 = icmp eq i32 %conv73, %shr81
90 br i1 %cmp82, label %lor.lhs.false, label %if.then
92 lor.lhs.false: ; preds = %for.body65
93 %idxprom87 = sext i32 %add861 to i64
94 %arrayidx89 = getelementptr inbounds i8* %tmp, i64 %idxprom87
95 %tmp90 = load i8* %arrayidx89, align 1
96 %conv91 = sext i8 %tmp90 to i32
97 %idxprom95 = sext i32 %add942 to i64
98 %arrayidx97 = getelementptr inbounds i32* %src, i64 %idxprom95
99 %tmp98 = load i32* %arrayidx97, align 4
100 %shr99 = ashr i32 %tmp98, 8
101 %cmp100 = icmp eq i32 %conv91, %shr99
102 br i1 %cmp100, label %lor.lhs.false102, label %if.then
104 lor.lhs.false102: ; preds = %lor.lhs.false
105 %idxprom106 = sext i32 %add1053 to i64
106 %arrayidx108 = getelementptr inbounds i8* %tmp, i64 %idxprom106
107 %tmp109 = load i8* %arrayidx108, align 1
108 %conv110 = sext i8 %tmp109 to i32
109 %idxprom114 = sext i32 %mul75 to i64
110 %arrayidx116 = getelementptr inbounds i32* %src, i64 %idxprom114
111 %tmp117 = load i32* %arrayidx116, align 4
112 %shr118 = ashr i32 %tmp117, 16
113 %cmp119 = icmp eq i32 %conv110, %shr118
114 br i1 %cmp119, label %lor.lhs.false121, label %if.then
116 lor.lhs.false121: ; preds = %lor.lhs.false102
117 %idxprom125 = sext i32 %add1244 to i64
118 %arrayidx127 = getelementptr inbounds i8* %tmp, i64 %idxprom125
119 %tmp128 = load i8* %arrayidx127, align 1
120 %conv129 = sext i8 %tmp128 to i32
121 %idxprom133 = sext i32 %mul75 to i64
122 %arrayidx135 = getelementptr inbounds i32* %src, i64 %idxprom133
123 %tmp136 = load i32* %arrayidx135, align 4
124 %cmp138 = icmp eq i32 %conv129, %tmp136
125 br i1 %cmp138, label %if.end, label %if.then
127 if.then: ; preds = %lor.lhs.false121, %lor.lhs.false102, %lor.lhs.false, %for.body65
128 call void @abort() noreturn nounwind
131 if.end: ; preds = %lor.lhs.false121
134 for.inc140: ; preds = %if.end
135 %inc142 = add nsw i32 %tmp23, 1
138 for.end143: ; preds = %for.cond59
142 declare void @abort() noreturn
144 define i32 @main() nounwind uwtable {
146 %d = alloca [256 x i32], align 16
147 %src = alloca [128 x i32], align 16
148 call void @check_vect()
151 for.cond: ; preds = %for.inc, %entry
152 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
153 %arrayidx = getelementptr [128 x i32]* %src, i64 0, i64 %indvar
154 %i.0 = trunc i64 %indvar to i32
155 %exitcond = icmp ne i64 %indvar, 128
156 br i1 %exitcond, label %for.body, label %for.end
158 for.body: ; preds = %for.cond
159 store i32 %i.0, i32* %arrayidx, align 4
162 for.inc: ; preds = %for.body
163 %indvar.next = add i64 %indvar, 1
166 for.end: ; preds = %for.cond
167 %arraydecay = getelementptr inbounds [256 x i32]* %d, i64 0, i64 0
168 %arraydecay4 = getelementptr inbounds [128 x i32]* %src, i64 0, i64 0
169 call void @ayuv2yuyv_ref(i32* %arraydecay, i32* %arraydecay4, i32 128)
173 define internal void @check_vect() nounwind uwtable noinline {
175 %a = alloca i32, align 4
176 %b = alloca i32, align 4
177 %c = alloca i32, align 4
178 %d = alloca i32, align 4
179 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
180 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
181 %tobool = icmp eq i32 %call1, 0
182 br i1 %tobool, label %if.then, label %lor.lhs.false
184 lor.lhs.false: ; preds = %entry
185 %tmp4 = load i32* %d, align 4
186 %and6 = and i32 %tmp4, 67108864
187 %cmp = icmp eq i32 %and6, 0
188 br i1 %cmp, label %if.then, label %if.end
190 if.then: ; preds = %entry, %lor.lhs.false
191 call void @exit(i32 0) noreturn nounwind
194 if.end: ; preds = %lor.lhs.false
195 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
199 declare void (i32)* @signal(i32, void (i32)*) nounwind
201 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
203 call void @exit(i32 0) noreturn nounwind
206 return: ; No predecessors!
210 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
212 %and = and i32 %__level, -2147483648
213 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
214 %cmp = icmp ult i32 %call, %__level
215 br i1 %cmp, label %if.then, label %if.end
217 if.then: ; preds = %entry
220 if.end: ; preds = %entry
221 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
222 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
223 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
224 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
225 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
226 store i32 %asmresult, i32* %__eax, align 4
227 store i32 %asmresult8, i32* %__ebx, align 4
228 store i32 %asmresult9, i32* %__ecx, align 4
229 store i32 %asmresult10, i32* %__edx, align 4
232 return: ; preds = %if.end, %if.then
233 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
237 declare void @exit(i32) noreturn
239 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
241 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
242 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
243 %tobool = icmp eq i32* %__sig, null
244 br i1 %tobool, label %if.end, label %if.then
246 if.then: ; preds = %entry
247 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
248 store i32 %asmresult1, i32* %__sig, align 4
251 if.end: ; preds = %entry, %if.then
255 !0 = metadata !{i32 -2147343361, i32 -2147343353}
256 !1 = metadata !{i32 -2147343484, i32 -2147343476}