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-same-dr.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-strided-same-dr.s > vect-strided-same-dr.ll
6 ; ModuleID = 'vect-strided-same-dr.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 }
12 @buffer1 = common global [128 x %struct.s] zeroinitializer, align 16
13 @buffer2 = common global [128 x %struct.s] zeroinitializer, align 16
15 define i32 @main1(%struct.s* noalias %pIn, %struct.s* noalias %pOut) nounwind uwtable noinline {
19 for.cond: ; preds = %for.inc, %entry
20 %indvar10 = phi i64 [ %indvar.next11, %for.inc ], [ 0, %entry ]
21 %tmp13 = mul i64 %indvar10, 2
22 %tmp14 = add i64 %tmp13, 1
23 %scevgep15 = getelementptr %struct.s* %pOut, i64 %tmp14
24 %a24 = bitcast %struct.s* %scevgep15 to i16*
25 %b29 = getelementptr %struct.s* %pOut, i64 %tmp14, i32 1
26 %b20 = getelementptr %struct.s* %pOut, i64 %tmp13, i32 1
27 %scevgep19 = getelementptr %struct.s* %pOut, i64 %tmp13
28 %a16 = bitcast %struct.s* %scevgep19 to i16*
29 %b = getelementptr %struct.s* %pIn, i64 %indvar10, i32 1
30 %scevgep22 = getelementptr %struct.s* %pIn, i64 %indvar10
31 %a = bitcast %struct.s* %scevgep22 to i16*
32 %exitcond = icmp ne i64 %indvar10, 64
33 br i1 %exitcond, label %for.body, label %for.end
35 for.body: ; preds = %for.cond
36 %tmp5 = load i16* %a, align 2
37 %add = add i16 %tmp5, 5
38 %add12 = add i16 %tmp5, 2
39 store i16 %add, i16* %a16, align 2
40 %tmp18 = load i16* %b, align 2
41 store i16 %tmp18, i16* %b20, align 2
42 store i16 %add12, i16* %a24, align 2
43 %tmp27 = load i16* %b, align 2
44 store i16 %tmp27, i16* %b29, align 2
47 for.inc: ; preds = %for.body
48 %indvar.next11 = add i64 %indvar10, 1
51 for.end: ; preds = %for.cond
54 for.cond35: ; preds = %for.inc92, %for.end
55 %indvar = phi i64 [ %indvar.next, %for.inc92 ], [ 0, %for.end ]
56 %b57 = getelementptr %struct.s* %pIn, i64 %indvar, i32 1
57 %scevgep = getelementptr %struct.s* %pIn, i64 %indvar
58 %a46 = bitcast %struct.s* %scevgep to i16*
59 %tmp = mul i64 %indvar, 2
60 %tmp2 = add i64 %tmp, 1
61 %scevgep3 = getelementptr %struct.s* %pOut, i64 %tmp2
62 %a65 = bitcast %struct.s* %scevgep3 to i16*
63 %b77 = getelementptr %struct.s* %pOut, i64 %tmp2, i32 1
64 %b53 = getelementptr %struct.s* %pOut, i64 %tmp, i32 1
65 %scevgep7 = getelementptr %struct.s* %pOut, i64 %tmp
66 %a42 = bitcast %struct.s* %scevgep7 to i16*
67 %i.1 = trunc i64 %indvar to i16
68 %cmp38 = icmp ult i16 %i.1, 64
69 br i1 %cmp38, label %for.body40, label %for.end95
71 for.body40: ; preds = %for.cond35
72 %tmp43 = load i16* %a42, align 2
73 %conv44 = zext i16 %tmp43 to i32
74 %tmp47 = load i16* %a46, align 2
75 %conv48 = zext i16 %tmp47 to i32
76 %add49 = add nsw i32 %conv48, 5
77 %cmp50 = icmp eq i32 %conv44, %add49
78 br i1 %cmp50, label %lor.lhs.false, label %if.then
80 lor.lhs.false: ; preds = %for.body40
81 %tmp54 = load i16* %b53, align 2
82 %tmp58 = load i16* %b57, align 2
83 %cmp60 = icmp eq i16 %tmp54, %tmp58
84 br i1 %cmp60, label %if.end, label %if.then
86 if.then: ; preds = %lor.lhs.false, %for.body40
87 call void @abort() noreturn nounwind
90 if.end: ; preds = %lor.lhs.false
91 %tmp66 = load i16* %a65, align 2
92 %conv67 = zext i16 %tmp66 to i32
93 %tmp70 = load i16* %a46, align 2
94 %conv71 = zext i16 %tmp70 to i32
95 %add72 = add nsw i32 %conv71, 2
96 %cmp73 = icmp eq i32 %conv67, %add72
97 br i1 %cmp73, label %lor.lhs.false75, label %if.then86
99 lor.lhs.false75: ; preds = %if.end
100 %tmp78 = load i16* %b77, align 2
101 %tmp82 = load i16* %b57, align 2
102 %cmp84 = icmp eq i16 %tmp78, %tmp82
103 br i1 %cmp84, label %if.end87, label %if.then86
105 if.then86: ; preds = %lor.lhs.false75, %if.end
106 call void @abort() noreturn nounwind
109 if.end87: ; preds = %lor.lhs.false75
112 for.inc92: ; preds = %if.end87
113 %indvar.next = add i64 %indvar, 1
116 for.end95: ; preds = %for.cond35
120 declare void @abort() noreturn
122 define i32 @main() nounwind uwtable {
126 for.cond: ; preds = %for.inc, %entry
127 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
128 %tmp = mul i64 %indvar, 2
129 %mul19 = trunc i64 %tmp to i16
130 %tmp3 = mul i64 %indvar, 3
131 %mul = trunc i64 %tmp3 to i16
132 %tmp5 = add i64 %indvar, 8
133 %add = trunc i64 %tmp5 to i16
134 %i.0 = trunc i64 %indvar to i16
135 %scevgep = getelementptr [128 x %struct.s]* @buffer1, i64 0, i64 %indvar
136 %a = bitcast %struct.s* %scevgep to i16*
137 %b24 = getelementptr [128 x %struct.s]* @buffer2, i64 0, i64 %indvar, i32 1
138 %scevgep10 = getelementptr [128 x %struct.s]* @buffer2, i64 0, i64 %indvar
139 %a16 = bitcast %struct.s* %scevgep10 to i16*
140 %b = getelementptr [128 x %struct.s]* @buffer1, i64 0, i64 %indvar, i32 1
141 %cmp = icmp slt i16 %i.0, 128
142 br i1 %cmp, label %for.body, label %for.end
144 for.body: ; preds = %for.cond
145 store i16 %i.0, i16* %a, align 4
146 store i16 %add, i16* %b, align 2
147 store i16 %mul, i16* %a16, align 4
148 store i16 %mul19, i16* %b24, align 2
149 %tmp29 = load i16* %a, align 4
150 %cmp31 = icmp eq i16 %tmp29, 500
151 br i1 %cmp31, label %if.then, label %if.end
153 if.then: ; preds = %for.body
154 call void @abort() noreturn nounwind
157 if.end: ; preds = %for.body
160 for.inc: ; preds = %if.end
161 %indvar.next = add i64 %indvar, 1
164 for.end: ; preds = %for.cond
165 call void @check_vect()
166 %call = call i32 @main1(%struct.s* getelementptr inbounds ([128 x %struct.s]* @buffer1, i64 0, i64 0), %struct.s* getelementptr inbounds ([128 x %struct.s]* @buffer2, i64 0, i64 0))
170 define internal void @check_vect() nounwind uwtable noinline {
172 %a = alloca i32, align 4
173 %b = alloca i32, align 4
174 %c = alloca i32, align 4
175 %d = alloca i32, align 4
176 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
177 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
178 %tobool = icmp eq i32 %call1, 0
179 br i1 %tobool, label %if.then, label %lor.lhs.false
181 lor.lhs.false: ; preds = %entry
182 %tmp4 = load i32* %d, align 4
183 %and6 = and i32 %tmp4, 67108864
184 %cmp = icmp eq i32 %and6, 0
185 br i1 %cmp, label %if.then, label %if.end
187 if.then: ; preds = %entry, %lor.lhs.false
188 call void @exit(i32 0) noreturn nounwind
191 if.end: ; preds = %lor.lhs.false
192 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
196 declare void (i32)* @signal(i32, void (i32)*) nounwind
198 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
200 call void @exit(i32 0) noreturn nounwind
203 return: ; No predecessors!
207 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
209 %and = and i32 %__level, -2147483648
210 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
211 %cmp = icmp ult i32 %call, %__level
212 br i1 %cmp, label %if.then, label %if.end
214 if.then: ; preds = %entry
217 if.end: ; preds = %entry
218 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
219 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
220 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
221 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
222 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
223 store i32 %asmresult, i32* %__eax, align 4
224 store i32 %asmresult8, i32* %__ebx, align 4
225 store i32 %asmresult9, i32* %__ecx, align 4
226 store i32 %asmresult10, i32* %__edx, align 4
229 return: ; preds = %if.end, %if.then
230 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
234 declare void @exit(i32) noreturn
236 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
238 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
239 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
240 %tobool = icmp eq i32* %__sig, null
241 br i1 %tobool, label %if.end, label %if.then
243 if.then: ; preds = %entry
244 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
245 store i32 %asmresult1, i32* %__sig, align 4
248 if.end: ; preds = %entry, %if.then
252 !0 = metadata !{i32 -2147343065, i32 -2147343057}
253 !1 = metadata !{i32 -2147343188, i32 -2147343180}