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-strided-mult.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-strided-mult.s > vect-strided-mult.ll
6 ; ModuleID = 'vect-strided-mult.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 { i16, i16 }
11 %struct.ii = type { i32, i32 }
13 define i32 @main1(%struct.s* %arr, %struct.ii* %iarr) nounwind uwtable noinline {
15 %res = alloca [128 x %struct.s], align 16
16 %ires = alloca [128 x %struct.ii], align 16
19 for.cond: ; preds = %for.inc, %entry
20 %indvar12 = phi i64 [ %indvar.next13, %for.inc ], [ 0, %entry ]
21 %scevgep14 = getelementptr %struct.s* %arr, i64 %indvar12
22 %a27 = bitcast %struct.s* %scevgep14 to i16*
23 %b24 = getelementptr %struct.s* %arr, i64 %indvar12, i32 1
24 %scevgep17 = getelementptr %struct.ii* %iarr, i64 %indvar12
25 %a = bitcast %struct.ii* %scevgep17 to i32*
26 %b = getelementptr %struct.ii* %iarr, i64 %indvar12, i32 1
27 %scevgep20 = getelementptr [128 x %struct.s]* %res, i64 0, i64 %indvar12
28 %a49 = bitcast %struct.s* %scevgep20 to i16*
29 %b35 = getelementptr [128 x %struct.s]* %res, i64 0, i64 %indvar12, i32 1
30 %b22 = getelementptr [128 x %struct.ii]* %ires, i64 0, i64 %indvar12, i32 1
31 %scevgep24 = getelementptr [128 x %struct.ii]* %ires, i64 0, i64 %indvar12
32 %a12 = bitcast %struct.ii* %scevgep24 to i32*
33 %exitcond = icmp ne i64 %indvar12, 128
34 br i1 %exitcond, label %for.body, label %for.end
36 for.body: ; preds = %for.cond
37 %tmp8 = load i32* %b, align 4
38 %tmp10 = load i32* %a, align 4
39 %sub = sub i32 %tmp8, %tmp10
40 store i32 %sub, i32* %a12, align 8
41 %tmp15 = load i32* %b, align 4
42 %tmp18 = load i32* %a, align 4
43 %add = add i32 %tmp15, %tmp18
44 store i32 %add, i32* %b22, align 4
45 %tmp25 = load i16* %b24, align 2
46 %tmp28 = load i16* %a27, align 2
47 %sub30 = sub i16 %tmp25, %tmp28
48 store i16 %sub30, i16* %b35, align 2
49 %tmp38 = load i16* %b24, align 2
50 %tmp42 = load i16* %a27, align 2
51 %add44 = add i16 %tmp38, %tmp42
52 store i16 %add44, i16* %a49, align 4
55 for.inc: ; preds = %for.body
56 %indvar.next13 = add i64 %indvar12, 1
59 for.end: ; preds = %for.cond
62 for.cond54: ; preds = %for.inc147, %for.end
63 %indvar = phi i64 [ %indvar.next, %for.inc147 ], [ 0, %for.end ]
64 %scevgep = getelementptr %struct.ii* %iarr, i64 %indvar
65 %a97 = bitcast %struct.ii* %scevgep to i32*
66 %b91 = getelementptr %struct.ii* %iarr, i64 %indvar, i32 1
67 %b130 = getelementptr [128 x %struct.ii]* %ires, i64 0, i64 %indvar, i32 1
68 %scevgep4 = getelementptr %struct.s* %arr, i64 %indvar
69 %a76 = bitcast %struct.s* %scevgep4 to i16*
70 %b69 = getelementptr %struct.s* %arr, i64 %indvar, i32 1
71 %scevgep7 = getelementptr [128 x %struct.s]* %res, i64 0, i64 %indvar
72 %a106 = bitcast %struct.s* %scevgep7 to i16*
73 %scevgep9 = getelementptr [128 x %struct.ii]* %ires, i64 0, i64 %indvar
74 %a85 = bitcast %struct.ii* %scevgep9 to i32*
75 %b62 = getelementptr [128 x %struct.s]* %res, i64 0, i64 %indvar, i32 1
76 %i.1 = trunc i64 %indvar to i32
77 %cmp56 = icmp slt i32 %i.1, 128
78 br i1 %cmp56, label %for.body58, label %for.end150
80 for.body58: ; preds = %for.cond54
81 %tmp63 = load i16* %b62, align 2
82 %conv64 = zext i16 %tmp63 to i32
83 %tmp70 = load i16* %b69, align 2
84 %conv71 = zext i16 %tmp70 to i32
85 %tmp77 = load i16* %a76, align 2
86 %conv78 = zext i16 %tmp77 to i32
87 %sub79 = sub nsw i32 %conv71, %conv78
88 %cmp80 = icmp eq i32 %conv64, %sub79
89 br i1 %cmp80, label %lor.lhs.false, label %if.then
91 lor.lhs.false: ; preds = %for.body58
92 %tmp86 = load i32* %a85, align 8
93 %tmp92 = load i32* %b91, align 4
94 %tmp98 = load i32* %a97, align 4
95 %sub99 = sub i32 %tmp92, %tmp98
96 %cmp100 = icmp eq i32 %tmp86, %sub99
97 br i1 %cmp100, label %lor.lhs.false102, label %if.then
99 lor.lhs.false102: ; preds = %lor.lhs.false
100 %tmp107 = load i16* %a106, align 4
101 %conv108 = zext i16 %tmp107 to i32
102 %tmp114 = load i16* %b69, align 2
103 %conv115 = zext i16 %tmp114 to i32
104 %tmp121 = load i16* %a76, align 2
105 %conv122 = zext i16 %tmp121 to i32
106 %add123 = add nsw i32 %conv115, %conv122
107 %cmp124 = icmp eq i32 %conv108, %add123
108 br i1 %cmp124, label %lor.lhs.false126, label %if.then
110 lor.lhs.false126: ; preds = %lor.lhs.false102
111 %tmp131 = load i32* %b130, align 4
112 %tmp137 = load i32* %b91, align 4
113 %tmp143 = load i32* %a97, align 4
114 %add144 = add i32 %tmp137, %tmp143
115 %cmp145 = icmp eq i32 %tmp131, %add144
116 br i1 %cmp145, label %if.end, label %if.then
118 if.then: ; preds = %lor.lhs.false126, %lor.lhs.false102, %lor.lhs.false, %for.body58
119 call void @abort() noreturn nounwind
122 if.end: ; preds = %lor.lhs.false126
125 for.inc147: ; preds = %if.end
126 %indvar.next = add i64 %indvar, 1
129 for.end150: ; preds = %for.cond54
133 declare void @abort() noreturn
135 define i32 @main() nounwind uwtable {
137 %arr = alloca [128 x %struct.s], align 16
138 %iarr = alloca [128 x %struct.ii], align 16
139 call void @check_vect()
142 for.cond: ; preds = %for.inc, %entry
143 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
144 %tmp = mul i64 %indvar, 2
145 %conv4 = trunc i64 %tmp to i16
146 %scevgep = getelementptr [128 x %struct.s]* %arr, i64 0, i64 %indvar
147 %a = bitcast %struct.s* %scevgep to i16*
148 %b18 = getelementptr [128 x %struct.ii]* %iarr, i64 0, i64 %indvar, i32 1
149 %tmp4 = mul i64 %indvar, 3
150 %mul14 = trunc i64 %tmp4 to i32
151 %scevgep6 = getelementptr [128 x %struct.ii]* %iarr, i64 0, i64 %indvar
152 %a12 = bitcast %struct.ii* %scevgep6 to i32*
153 %i.0 = trunc i64 %indvar to i32
154 %b = getelementptr [128 x %struct.s]* %arr, i64 0, i64 %indvar, i32 1
155 %conv = trunc i64 %indvar to i16
156 %cmp = icmp slt i32 %i.0, 128
157 br i1 %cmp, label %for.body, label %for.end
159 for.body: ; preds = %for.cond
160 store i16 %conv, i16* %a, align 4
161 store i16 %conv4, i16* %b, align 2
162 store i32 %i.0, i32* %a12, align 8
163 store i32 %mul14, i32* %b18, align 4
164 %tmp23 = load i16* %a, align 4
165 %cmp25 = icmp eq i16 %tmp23, 178
166 br i1 %cmp25, label %if.then, label %if.end
168 if.then: ; preds = %for.body
169 call void @abort() noreturn nounwind
172 if.end: ; preds = %for.body
175 for.inc: ; preds = %if.end
176 %indvar.next = add i64 %indvar, 1
179 for.end: ; preds = %for.cond
180 %arraydecay = getelementptr inbounds [128 x %struct.s]* %arr, i64 0, i64 0
181 %arraydecay28 = getelementptr inbounds [128 x %struct.ii]* %iarr, i64 0, i64 0
182 %call = call i32 @main1(%struct.s* %arraydecay, %struct.ii* %arraydecay28)
186 define internal void @check_vect() nounwind uwtable noinline {
188 %a = alloca i32, align 4
189 %b = alloca i32, align 4
190 %c = alloca i32, align 4
191 %d = alloca i32, align 4
192 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
193 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
194 %tobool = icmp eq i32 %call1, 0
195 br i1 %tobool, label %if.then, label %lor.lhs.false
197 lor.lhs.false: ; preds = %entry
198 %tmp4 = load i32* %d, align 4
199 %and6 = and i32 %tmp4, 67108864
200 %cmp = icmp eq i32 %and6, 0
201 br i1 %cmp, label %if.then, label %if.end
203 if.then: ; preds = %entry, %lor.lhs.false
204 call void @exit(i32 0) noreturn nounwind
207 if.end: ; preds = %lor.lhs.false
208 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
212 declare void (i32)* @signal(i32, void (i32)*) nounwind
214 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
216 call void @exit(i32 0) noreturn nounwind
219 return: ; No predecessors!
223 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
225 %and = and i32 %__level, -2147483648
226 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
227 %cmp = icmp ult i32 %call, %__level
228 br i1 %cmp, label %if.then, label %if.end
230 if.then: ; preds = %entry
233 if.end: ; preds = %entry
234 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
235 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
236 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
237 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
238 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
239 store i32 %asmresult, i32* %__eax, align 4
240 store i32 %asmresult8, i32* %__ebx, align 4
241 store i32 %asmresult9, i32* %__ecx, align 4
242 store i32 %asmresult10, i32* %__edx, align 4
245 return: ; preds = %if.end, %if.then
246 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
250 declare void @exit(i32) noreturn
252 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
254 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
255 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
256 %tobool = icmp eq i32* %__sig, null
257 br i1 %tobool, label %if.end, label %if.then
259 if.then: ; preds = %entry
260 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
261 store i32 %asmresult1, i32* %__sig, align 4
264 if.end: ; preds = %entry, %if.then
268 !0 = metadata !{i32 -2147343034, i32 -2147343026}
269 !1 = metadata !{i32 -2147343157, i32 -2147343149}