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-u8-i2.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-strided-u8-i2.s > vect-strided-u8-i2.ll
6 ; ModuleID = 'vect-strided-u8-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 { i8, i8 }
12 define i32 @main1(%struct.s* %arr) nounwind uwtable noinline {
14 %res = alloca [64 x %struct.s], align 16
17 for.cond: ; preds = %for.inc, %entry
18 %indvar5 = phi i64 [ %indvar.next6, %for.inc ], [ 0, %entry ]
19 %scevgep7 = getelementptr %struct.s* %arr, i64 %indvar5
20 %a = bitcast %struct.s* %scevgep7 to i8*
21 %b = getelementptr %struct.s* %arr, i64 %indvar5, i32 1
22 %b24 = getelementptr [64 x %struct.s]* %res, i64 0, i64 %indvar5, i32 1
23 %scevgep11 = getelementptr [64 x %struct.s]* %res, i64 0, i64 %indvar5
24 %a11 = bitcast %struct.s* %scevgep11 to i8*
25 %exitcond = icmp ne i64 %indvar5, 64
26 br i1 %exitcond, label %for.body, label %for.end
28 for.body: ; preds = %for.cond
29 %tmp5 = load i8* %b, align 1
30 %tmp7 = load i8* %a, align 1
31 %sub = sub i8 %tmp5, %tmp7
32 store i8 %sub, i8* %a11, align 2
33 %tmp14 = load i8* %b, align 1
34 %tmp18 = load i8* %a, align 1
35 %add = add i8 %tmp14, %tmp18
36 store i8 %add, i8* %b24, align 1
39 for.inc: ; preds = %for.body
40 %indvar.next6 = add i64 %indvar5, 1
43 for.end: ; preds = %for.cond
46 for.cond27: ; preds = %for.inc78, %for.end
47 %indvar = phi i64 [ %indvar.next, %for.inc78 ], [ 0, %for.end ]
48 %b42 = getelementptr %struct.s* %arr, i64 %indvar, i32 1
49 %scevgep = getelementptr %struct.s* %arr, i64 %indvar
50 %a49 = bitcast %struct.s* %scevgep to i8*
51 %b58 = getelementptr [64 x %struct.s]* %res, i64 0, i64 %indvar, i32 1
52 %scevgep3 = getelementptr [64 x %struct.s]* %res, i64 0, i64 %indvar
53 %a35 = bitcast %struct.s* %scevgep3 to i8*
54 %i.1 = trunc i64 %indvar to i32
55 %cmp29 = icmp slt i32 %i.1, 64
56 br i1 %cmp29, label %for.body31, label %for.end81
58 for.body31: ; preds = %for.cond27
59 %tmp36 = load i8* %a35, align 2
60 %conv37 = zext i8 %tmp36 to i32
61 %tmp43 = load i8* %b42, align 1
62 %conv44 = zext i8 %tmp43 to i32
63 %tmp50 = load i8* %a49, align 1
64 %conv51 = zext i8 %tmp50 to i32
65 %sub52 = sub nsw i32 %conv44, %conv51
66 %cmp53 = icmp eq i32 %conv37, %sub52
67 br i1 %cmp53, label %lor.lhs.false, label %if.then
69 lor.lhs.false: ; preds = %for.body31
70 %tmp59 = load i8* %b58, align 1
71 %conv60 = zext i8 %tmp59 to i32
72 %tmp66 = load i8* %a49, align 1
73 %conv67 = zext i8 %tmp66 to i32
74 %tmp73 = load i8* %b42, align 1
75 %conv74 = zext i8 %tmp73 to i32
76 %add75 = add nsw i32 %conv67, %conv74
77 %cmp76 = icmp eq i32 %conv60, %add75
78 br i1 %cmp76, label %if.end, label %if.then
80 if.then: ; preds = %lor.lhs.false, %for.body31
81 call void @abort() noreturn nounwind
84 if.end: ; preds = %lor.lhs.false
87 for.inc78: ; preds = %if.end
88 %indvar.next = add i64 %indvar, 1
91 for.end81: ; preds = %for.cond27
95 declare void @abort() noreturn
97 define i32 @main() nounwind uwtable {
99 %arr = alloca [64 x %struct.s], align 16
100 call void @check_vect()
103 for.cond: ; preds = %for.inc, %entry
104 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
105 %tmp = mul i64 %indvar, 2
106 %conv4 = trunc i64 %tmp to i8
107 %scevgep = getelementptr [64 x %struct.s]* %arr, i64 0, i64 %indvar
108 %a = bitcast %struct.s* %scevgep to i8*
109 %b = getelementptr [64 x %struct.s]* %arr, i64 0, i64 %indvar, i32 1
110 %conv = trunc i64 %indvar to i8
111 %i.0 = trunc i64 %indvar to i32
112 %cmp = icmp slt i32 %i.0, 64
113 br i1 %cmp, label %for.body, label %for.end
115 for.body: ; preds = %for.cond
116 store i8 %conv, i8* %a, align 2
117 store i8 %conv4, i8* %b, align 1
118 %tmp12 = load i8* %a, align 2
119 %cmp14 = icmp eq i8 %tmp12, -78
120 br i1 %cmp14, label %if.then, label %if.end
122 if.then: ; preds = %for.body
123 call void @abort() noreturn nounwind
126 if.end: ; preds = %for.body
129 for.inc: ; preds = %if.end
130 %indvar.next = add i64 %indvar, 1
133 for.end: ; preds = %for.cond
134 %arraydecay = getelementptr inbounds [64 x %struct.s]* %arr, i64 0, i64 0
135 %call = call i32 @main1(%struct.s* %arraydecay)
139 define internal void @check_vect() nounwind uwtable noinline {
141 %a = alloca i32, align 4
142 %b = alloca i32, align 4
143 %c = alloca i32, align 4
144 %d = alloca i32, align 4
145 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
146 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
147 %tobool = icmp eq i32 %call1, 0
148 br i1 %tobool, label %if.then, label %lor.lhs.false
150 lor.lhs.false: ; preds = %entry
151 %tmp4 = load i32* %d, align 4
152 %and6 = and i32 %tmp4, 67108864
153 %cmp = icmp eq i32 %and6, 0
154 br i1 %cmp, label %if.then, label %if.end
156 if.then: ; preds = %entry, %lor.lhs.false
157 call void @exit(i32 0) noreturn nounwind
160 if.end: ; preds = %lor.lhs.false
161 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
165 declare void (i32)* @signal(i32, void (i32)*) nounwind
167 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
169 call void @exit(i32 0) noreturn nounwind
172 return: ; No predecessors!
176 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
178 %and = and i32 %__level, -2147483648
179 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
180 %cmp = icmp ult i32 %call, %__level
181 br i1 %cmp, label %if.then, label %if.end
183 if.then: ; preds = %entry
186 if.end: ; preds = %entry
187 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
188 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
189 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
190 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
191 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
192 store i32 %asmresult, i32* %__eax, align 4
193 store i32 %asmresult8, i32* %__ebx, align 4
194 store i32 %asmresult9, i32* %__ecx, align 4
195 store i32 %asmresult10, i32* %__edx, align 4
198 return: ; preds = %if.end, %if.then
199 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
203 declare void @exit(i32) noreturn
205 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
207 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
208 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
209 %tobool = icmp eq i32* %__sig, null
210 br i1 %tobool, label %if.end, label %if.then
212 if.then: ; preds = %entry
213 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
214 store i32 %asmresult1, i32* %__sig, align 4
217 if.end: ; preds = %entry, %if.then
221 !0 = metadata !{i32 -2147343397, i32 -2147343389}
222 !1 = metadata !{i32 -2147343520, i32 -2147343512}