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 slp-24.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer slp-24.s > slp-24.ll
6 ; ModuleID = 'slp-24.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 %struct.s = type { i8, i8, i8, i8 }
12 @ub = global [32 x i8] c"\01\03\06\09\0C\0F\12\15\18\1B\1E!$'*-\01\03\06\09\0C\0F\12\15\18\1B\1E!$'*-", align 16
13 @uc = global [16 x i8] c"\01\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F", align 16
15 define void @main1(i8 zeroext %x, i8 zeroext %max_result, i8 zeroext %min_result, %struct.s* %arr) nounwind uwtable {
17 %ua1 = alloca [32 x i8], align 16
18 %out = alloca [16 x %struct.s], align 16
21 for.cond: ; preds = %for.inc, %entry
22 %indvar11 = phi i64 [ %indvar.next12, %for.inc ], [ 0, %entry ]
23 %udiff.0 = phi i32 [ 2, %entry ], [ %phitmp, %for.inc ]
24 %tmp14 = mul i64 %indvar11, 2
25 %arrayidx38 = getelementptr [32 x i8]* %ua1, i64 0, i64 %tmp14
26 %arrayidx33 = getelementptr [32 x i8]* @ub, i64 0, i64 %tmp14
27 %tmp17 = add i64 %tmp14, 1
28 %arrayidx29 = getelementptr [32 x i8]* %ua1, i64 0, i64 %tmp17
29 %arrayidx23 = getelementptr [32 x i8]* @ub, i64 0, i64 %tmp17
30 %scevgep20 = getelementptr [16 x %struct.s]* %out, i64 0, i64 %indvar11
31 %a74 = bitcast %struct.s* %scevgep20 to i8*
32 %c65 = getelementptr [16 x %struct.s]* %out, i64 0, i64 %indvar11, i32 2
33 %b56 = getelementptr [16 x %struct.s]* %out, i64 0, i64 %indvar11, i32 1
34 %d47 = getelementptr [16 x %struct.s]* %out, i64 0, i64 %indvar11, i32 3
35 %arrayidx12 = getelementptr [16 x i8]* @uc, i64 0, i64 %indvar11
36 %arrayidx = getelementptr [32 x i8]* @ub, i64 0, i64 %indvar11
37 %scevgep28 = getelementptr %struct.s* %arr, i64 %indvar11
38 %a = bitcast %struct.s* %scevgep28 to i8*
39 %c = getelementptr %struct.s* %arr, i64 %indvar11, i32 2
40 %b = getelementptr %struct.s* %arr, i64 %indvar11, i32 1
41 %d = getelementptr %struct.s* %arr, i64 %indvar11, i32 3
42 %exitcond = icmp ne i64 %indvar11, 16
43 br i1 %exitcond, label %for.body, label %for.end
45 for.body: ; preds = %for.cond
46 %tmp9 = load i8* %arrayidx, align 1
47 %tmp13 = load i8* %arrayidx12, align 1
48 %tmp24 = load i8* %arrayidx23, align 1
49 store i8 %tmp24, i8* %arrayidx29, align 1
50 %tmp34 = load i8* %arrayidx33, align 2
51 store i8 %tmp34, i8* %arrayidx38, align 2
52 %tmp40 = load i8* %d, align 1
53 %sub42 = add i8 %tmp40, -1
54 store i8 %sub42, i8* %d47, align 1
55 %tmp49 = load i8* %b, align 1
56 %sub51 = add i8 %tmp49, -4
57 store i8 %sub51, i8* %b56, align 1
58 %tmp58 = load i8* %c, align 1
59 %sub60 = add i8 %tmp58, -8
60 store i8 %sub60, i8* %c65, align 2
61 %tmp67 = load i8* %a, align 1
62 %sub69 = add i8 %tmp67, -3
63 store i8 %sub69, i8* %a74, align 4
66 for.inc: ; preds = %for.body
67 %sub = sub i8 %tmp9, %tmp13
68 %conv16 = zext i8 %sub to i32
69 %add = add nsw i32 %udiff.0, %conv16
70 %phitmp = and i32 %add, 255
71 %indvar.next12 = add i64 %indvar11, 1
74 for.end: ; preds = %for.cond
75 %udiff.0.lcssa = phi i32 [ %udiff.0, %for.cond ]
78 for.cond77: ; preds = %for.inc180, %for.end
79 %indvar = phi i64 [ %indvar.next, %for.inc180 ], [ 0, %for.end ]
80 %tmp = mul i64 %indvar, 2
81 %tmp5 = add i64 %tmp, 1
82 %arrayidx107 = getelementptr [32 x i8]* @ub, i64 0, i64 %tmp5
83 %arrayidx100 = getelementptr [32 x i8]* %ua1, i64 0, i64 %tmp5
84 %arrayidx91 = getelementptr [32 x i8]* @ub, i64 0, i64 %tmp
85 %arrayidx85 = getelementptr [32 x i8]* %ua1, i64 0, i64 %tmp
86 %d174 = getelementptr %struct.s* %arr, i64 %indvar, i32 3
87 %d167 = getelementptr [16 x %struct.s]* %out, i64 0, i64 %indvar, i32 3
88 %c157 = getelementptr %struct.s* %arr, i64 %indvar, i32 2
89 %c150 = getelementptr [16 x %struct.s]* %out, i64 0, i64 %indvar, i32 2
90 %b140 = getelementptr %struct.s* %arr, i64 %indvar, i32 1
91 %b133 = getelementptr [16 x %struct.s]* %out, i64 0, i64 %indvar, i32 1
92 %scevgep = getelementptr %struct.s* %arr, i64 %indvar
93 %a123 = bitcast %struct.s* %scevgep to i8*
94 %scevgep7 = getelementptr [16 x %struct.s]* %out, i64 0, i64 %indvar
95 %a116 = bitcast %struct.s* %scevgep7 to i8*
96 %i.1 = trunc i64 %indvar to i32
97 %cmp79 = icmp slt i32 %i.1, 16
98 br i1 %cmp79, label %for.body81, label %for.end183
100 for.body81: ; preds = %for.cond77
101 %tmp86 = load i8* %arrayidx85, align 2
102 %tmp92 = load i8* %arrayidx91, align 2
103 %cmp94 = icmp eq i8 %tmp86, %tmp92
104 br i1 %cmp94, label %lor.lhs.false, label %if.then
106 lor.lhs.false: ; preds = %for.body81
107 %tmp101 = load i8* %arrayidx100, align 1
108 %tmp108 = load i8* %arrayidx107, align 1
109 %cmp110 = icmp eq i8 %tmp101, %tmp108
110 br i1 %cmp110, label %lor.lhs.false112, label %if.then
112 lor.lhs.false112: ; preds = %lor.lhs.false
113 %tmp117 = load i8* %a116, align 4
114 %conv118 = zext i8 %tmp117 to i32
115 %tmp124 = load i8* %a123, align 1
116 %conv125 = zext i8 %tmp124 to i32
117 %sub126 = add nsw i32 %conv125, -3
118 %cmp127 = icmp eq i32 %conv118, %sub126
119 br i1 %cmp127, label %lor.lhs.false129, label %if.then
121 lor.lhs.false129: ; preds = %lor.lhs.false112
122 %tmp134 = load i8* %b133, align 1
123 %conv135 = zext i8 %tmp134 to i32
124 %tmp141 = load i8* %b140, align 1
125 %conv142 = zext i8 %tmp141 to i32
126 %sub143 = add nsw i32 %conv142, -4
127 %cmp144 = icmp eq i32 %conv135, %sub143
128 br i1 %cmp144, label %lor.lhs.false146, label %if.then
130 lor.lhs.false146: ; preds = %lor.lhs.false129
131 %tmp151 = load i8* %c150, align 2
132 %conv152 = zext i8 %tmp151 to i32
133 %tmp158 = load i8* %c157, align 1
134 %conv159 = zext i8 %tmp158 to i32
135 %sub160 = add nsw i32 %conv159, -8
136 %cmp161 = icmp eq i32 %conv152, %sub160
137 br i1 %cmp161, label %lor.lhs.false163, label %if.then
139 lor.lhs.false163: ; preds = %lor.lhs.false146
140 %tmp168 = load i8* %d167, align 1
141 %conv169 = zext i8 %tmp168 to i32
142 %tmp175 = load i8* %d174, align 1
143 %conv176 = zext i8 %tmp175 to i32
144 %sub177 = add nsw i32 %conv176, -1
145 %cmp178 = icmp eq i32 %conv169, %sub177
146 br i1 %cmp178, label %if.end, label %if.then
148 if.then: ; preds = %lor.lhs.false163, %lor.lhs.false146, %lor.lhs.false129, %lor.lhs.false112, %lor.lhs.false, %for.body81
149 call void @abort() noreturn nounwind
152 if.end: ; preds = %lor.lhs.false163
155 for.inc180: ; preds = %if.end
156 %indvar.next = add i64 %indvar, 1
159 for.end183: ; preds = %for.cond77
160 %cmp186 = icmp eq i32 %udiff.0.lcssa, 242
161 br i1 %cmp186, label %if.end189, label %if.then188
163 if.then188: ; preds = %for.end183
164 call void @abort() noreturn nounwind
167 if.end189: ; preds = %for.end183
171 declare void @abort() noreturn
173 define i32 @main() nounwind uwtable {
175 %arr = alloca [16 x %struct.s], align 16
178 for.cond: ; preds = %for.inc, %entry
179 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
180 %tmp = mul i64 %indvar, 2
181 %tmp1 = add i64 %tmp, 10
182 %conv5 = trunc i64 %tmp1 to i8
183 %scevgep = getelementptr [16 x %struct.s]* %arr, i64 0, i64 %indvar
184 %a = bitcast %struct.s* %scevgep to i8*
185 %d = getelementptr [16 x %struct.s]* %arr, i64 0, i64 %indvar, i32 3
186 %tmp5 = add i64 %indvar, 34
187 %conv14 = trunc i64 %tmp5 to i8
188 %c = getelementptr [16 x %struct.s]* %arr, i64 0, i64 %indvar, i32 2
189 %b = getelementptr [16 x %struct.s]* %arr, i64 0, i64 %indvar, i32 1
190 %tmp9 = add i64 %indvar, 9
191 %conv = trunc i64 %tmp9 to i8
192 %i.0 = trunc i64 %indvar to i32
193 %cmp = icmp slt i32 %i.0, 16
194 br i1 %cmp, label %for.body, label %for.end
196 for.body: ; preds = %for.cond
197 store i8 %conv, i8* %a, align 4
198 store i8 %conv5, i8* %b, align 1
199 store i8 17, i8* %c, align 2
200 store i8 %conv14, i8* %d, align 1
201 %tmp22 = load i8* %a, align 4
202 %cmp24 = icmp eq i8 %tmp22, -78
203 br i1 %cmp24, label %if.then, label %if.end
205 if.then: ; preds = %for.body
206 call void @abort() noreturn nounwind
209 if.end: ; preds = %for.body
212 for.inc: ; preds = %if.end
213 %indvar.next = add i64 %indvar, 1
216 for.end: ; preds = %for.cond
217 call void @check_vect()
218 %arraydecay = getelementptr inbounds [16 x %struct.s]* %arr, i64 0, i64 0
219 call void @main1(i8 zeroext 100, i8 zeroext 100, i8 zeroext 1, %struct.s* %arraydecay)
220 %arraydecay27 = getelementptr inbounds [16 x %struct.s]* %arr, i64 0, i64 0
221 call void @main1(i8 zeroext 0, i8 zeroext 15, i8 zeroext 0, %struct.s* %arraydecay27)
225 define internal void @check_vect() nounwind uwtable noinline {
227 %a = alloca i32, align 4
228 %b = alloca i32, align 4
229 %c = alloca i32, align 4
230 %d = alloca i32, align 4
231 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
232 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
233 %tobool = icmp eq i32 %call1, 0
234 br i1 %tobool, label %if.then, label %lor.lhs.false
236 lor.lhs.false: ; preds = %entry
237 %tmp4 = load i32* %d, align 4
238 %and6 = and i32 %tmp4, 67108864
239 %cmp = icmp eq i32 %and6, 0
240 br i1 %cmp, label %if.then, label %if.end
242 if.then: ; preds = %entry, %lor.lhs.false
243 call void @exit(i32 0) noreturn nounwind
246 if.end: ; preds = %lor.lhs.false
247 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
251 declare void (i32)* @signal(i32, void (i32)*) nounwind
253 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
255 call void @exit(i32 0) noreturn nounwind
258 return: ; No predecessors!
262 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
264 %and = and i32 %__level, -2147483648
265 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
266 %cmp = icmp ult i32 %call, %__level
267 br i1 %cmp, label %if.then, label %if.end
269 if.then: ; preds = %entry
272 if.end: ; preds = %entry
273 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
274 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
275 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
276 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
277 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
278 store i32 %asmresult, i32* %__eax, align 4
279 store i32 %asmresult8, i32* %__ebx, align 4
280 store i32 %asmresult9, i32* %__ecx, align 4
281 store i32 %asmresult10, i32* %__edx, align 4
284 return: ; preds = %if.end, %if.then
285 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
289 declare void @exit(i32) noreturn
291 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
293 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
294 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
295 %tobool = icmp eq i32* %__sig, null
296 br i1 %tobool, label %if.end, label %if.then
298 if.then: ; preds = %entry
299 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
300 store i32 %asmresult1, i32* %__sig, align 4
303 if.end: ; preds = %entry, %if.then
307 !0 = metadata !{i32 -2147342525, i32 -2147342517}
308 !1 = metadata !{i32 -2147342648, i32 -2147342640}