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-a-u16-i2.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-strided-a-u16-i2.s > vect-strided-a-u16-i2.ll
6 ; ModuleID = 'vect-strided-a-u16-i2.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 define i32 @main1() nounwind uwtable noinline {
14 %arr = alloca [128 x %struct.s], align 16
15 %res = alloca [128 x %struct.s], align 16
18 for.cond: ; preds = %for.inc, %entry
19 %indvar13 = phi i64 [ %indvar.next14, %for.inc ], [ 0, %entry ]
20 %tmp = mul i64 %indvar13, 2
21 %conv4 = trunc i64 %tmp to i16
22 %scevgep16 = getelementptr [128 x %struct.s]* %arr, i64 0, i64 %indvar13
23 %a = bitcast %struct.s* %scevgep16 to i16*
24 %b = getelementptr [128 x %struct.s]* %arr, i64 0, i64 %indvar13, i32 1
25 %conv = trunc i64 %indvar13 to i16
26 %i.0 = trunc i64 %indvar13 to i32
27 %cmp = icmp slt i32 %i.0, 128
28 br i1 %cmp, label %for.body, label %for.end
30 for.body: ; preds = %for.cond
31 store i16 %conv, i16* %a, align 4
32 store i16 %conv4, i16* %b, align 2
33 %tmp12 = load i16* %a, align 4
34 %cmp14 = icmp eq i16 %tmp12, 178
35 br i1 %cmp14, label %if.then, label %if.end
37 if.then: ; preds = %for.body
38 call void @abort() noreturn nounwind
41 if.end: ; preds = %for.body
44 for.inc: ; preds = %if.end
45 %indvar.next14 = add i64 %indvar13, 1
48 for.end: ; preds = %for.cond
51 for.cond17: ; preds = %for.inc49, %for.end
52 %indvar5 = phi i64 [ %indvar.next6, %for.inc49 ], [ 0, %for.end ]
53 %b47 = getelementptr [128 x %struct.s]* %res, i64 0, i64 %indvar5, i32 1
54 %scevgep8 = getelementptr [128 x %struct.s]* %res, i64 0, i64 %indvar5
55 %a34 = bitcast %struct.s* %scevgep8 to i16*
56 %scevgep10 = getelementptr [128 x %struct.s]* %arr, i64 0, i64 %indvar5
57 %a27 = bitcast %struct.s* %scevgep10 to i16*
58 %b23 = getelementptr [128 x %struct.s]* %arr, i64 0, i64 %indvar5, i32 1
59 %exitcond = icmp ne i64 %indvar5, 128
60 br i1 %exitcond, label %for.body21, label %for.end52
62 for.body21: ; preds = %for.cond17
63 %tmp24 = load i16* %b23, align 2
64 %tmp28 = load i16* %a27, align 2
65 %sub = sub i16 %tmp24, %tmp28
66 store i16 %sub, i16* %a34, align 4
67 %tmp37 = load i16* %b23, align 2
68 %tmp41 = load i16* %a27, align 2
69 %add = add i16 %tmp37, %tmp41
70 store i16 %add, i16* %b47, align 2
73 for.inc49: ; preds = %for.body21
74 %indvar.next6 = add i64 %indvar5, 1
77 for.end52: ; preds = %for.cond17
80 for.cond53: ; preds = %for.inc102, %for.end52
81 %indvar = phi i64 [ %indvar.next, %for.inc102 ], [ 0, %for.end52 ]
82 %b67 = getelementptr [128 x %struct.s]* %arr, i64 0, i64 %indvar, i32 1
83 %scevgep = getelementptr [128 x %struct.s]* %arr, i64 0, i64 %indvar
84 %a73 = bitcast %struct.s* %scevgep to i16*
85 %b82 = getelementptr [128 x %struct.s]* %res, i64 0, i64 %indvar, i32 1
86 %scevgep3 = getelementptr [128 x %struct.s]* %res, i64 0, i64 %indvar
87 %a61 = bitcast %struct.s* %scevgep3 to i16*
88 %i.2 = trunc i64 %indvar to i32
89 %cmp55 = icmp slt i32 %i.2, 128
90 br i1 %cmp55, label %for.body57, label %for.end105
92 for.body57: ; preds = %for.cond53
93 %tmp62 = load i16* %a61, align 4
94 %conv63 = zext i16 %tmp62 to i32
95 %tmp68 = load i16* %b67, align 2
96 %conv69 = zext i16 %tmp68 to i32
97 %tmp74 = load i16* %a73, align 4
98 %conv75 = zext i16 %tmp74 to i32
99 %sub76 = sub nsw i32 %conv69, %conv75
100 %cmp77 = icmp eq i32 %conv63, %sub76
101 br i1 %cmp77, label %lor.lhs.false, label %if.then100
103 lor.lhs.false: ; preds = %for.body57
104 %tmp83 = load i16* %b82, align 2
105 %conv84 = zext i16 %tmp83 to i32
106 %tmp89 = load i16* %a73, align 4
107 %conv90 = zext i16 %tmp89 to i32
108 %tmp95 = load i16* %b67, align 2
109 %conv96 = zext i16 %tmp95 to i32
110 %add97 = add nsw i32 %conv90, %conv96
111 %cmp98 = icmp eq i32 %conv84, %add97
112 br i1 %cmp98, label %if.end101, label %if.then100
114 if.then100: ; preds = %lor.lhs.false, %for.body57
115 call void @abort() noreturn nounwind
118 if.end101: ; preds = %lor.lhs.false
121 for.inc102: ; preds = %if.end101
122 %indvar.next = add i64 %indvar, 1
125 for.end105: ; preds = %for.cond53
129 declare void @abort() noreturn
131 define i32 @main() nounwind uwtable {
133 call void @check_vect()
134 %call = call i32 @main1()
138 define internal void @check_vect() nounwind uwtable noinline {
140 %a = alloca i32, align 4
141 %b = alloca i32, align 4
142 %c = alloca i32, align 4
143 %d = alloca i32, align 4
144 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
145 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
146 %tobool = icmp eq i32 %call1, 0
147 br i1 %tobool, label %if.then, label %lor.lhs.false
149 lor.lhs.false: ; preds = %entry
150 %tmp4 = load i32* %d, align 4
151 %and6 = and i32 %tmp4, 67108864
152 %cmp = icmp eq i32 %and6, 0
153 br i1 %cmp, label %if.then, label %if.end
155 if.then: ; preds = %entry, %lor.lhs.false
156 call void @exit(i32 0) noreturn nounwind
159 if.end: ; preds = %lor.lhs.false
160 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
164 declare void (i32)* @signal(i32, void (i32)*) nounwind
166 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
168 call void @exit(i32 0) noreturn nounwind
171 return: ; No predecessors!
175 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
177 %and = and i32 %__level, -2147483648
178 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
179 %cmp = icmp ult i32 %call, %__level
180 br i1 %cmp, label %if.then, label %if.end
182 if.then: ; preds = %entry
185 if.end: ; preds = %entry
186 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
187 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
188 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
189 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
190 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
191 store i32 %asmresult, i32* %__eax, align 4
192 store i32 %asmresult8, i32* %__ebx, align 4
193 store i32 %asmresult9, i32* %__ecx, align 4
194 store i32 %asmresult10, i32* %__edx, align 4
197 return: ; preds = %if.end, %if.then
198 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
202 declare void @exit(i32) noreturn
204 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
206 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
207 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
208 %tobool = icmp eq i32* %__sig, null
209 br i1 %tobool, label %if.end, label %if.then
211 if.then: ; preds = %entry
212 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
213 store i32 %asmresult1, i32* %__sig, align 4
216 if.end: ; preds = %entry, %if.then
220 !0 = metadata !{i32 -2147343403, i32 -2147343395}
221 !1 = metadata !{i32 -2147343526, i32 -2147343518}