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-cselim-1.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-cselim-1.s > vect-cselim-1.ll
6 ; ModuleID = 'vect-cselim-1.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.data = type { i16, i16 }
12 @result = global [100 x i16] [i16 7, i16 -7, i16 9, i16 -6, i16 11, i16 -5, i16 13, i16 -4, i16 15, i16 -3, i16 17, i16 -2, i16 19, i16 -1, i16 21, i16 0, i16 23, i16 1, i16 25, i16 2, i16 27, i16 3, i16 29, i16 4, i16 31, i16 5, i16 33, i16 6, i16 35, i16 7, i16 37, i16 8, i16 39, i16 9, i16 41, i16 10, i16 43, i16 11, i16 45, i16 12, i16 47, i16 13, i16 49, i16 14, i16 51, i16 15, i16 53, i16 16, i16 55, i16 17, i16 57, i16 18, i16 59, i16 19, i16 61, i16 20, i16 63, i16 21, i16 65, i16 22, i16 67, i16 23, i16 69, i16 24, i16 71, i16 25, i16 73, i16 26, i16 75, i16 27, i16 77, i16 28, i16 79, i16 29, i16 81, i16 30, i16 83, i16 31, i16 85, i16 32, i16 87, i16 33, i16 89, i16 34, i16 91, i16 35, i16 93, i16 36, i16 95, i16 37, i16 97, i16 38, i16 99, i16 39, i16 101, i16 40, i16 103, i16 41, i16 105, i16 42], align 16
13 @in1 = common global [50 x %struct.data] zeroinitializer, align 16
14 @in2 = common global [50 x %struct.data] zeroinitializer, align 16
15 @out = common global [50 x %struct.data] zeroinitializer, align 16
16 @out1 = common global [50 x i16] zeroinitializer, align 16
17 @out2 = common global [50 x i16] zeroinitializer, align 16
19 define void @foo() nounwind uwtable noinline {
23 for.cond: ; preds = %for.inc, %entry
24 %indvar7 = phi i64 [ %indvar.next8, %for.inc ], [ 0, %entry ]
25 %scevgep = getelementptr [50 x %struct.data]* @out, i64 0, i64 %indvar7
26 %a = bitcast %struct.data* %scevgep to i16*
27 %b17 = getelementptr [50 x %struct.data]* @out, i64 0, i64 %indvar7, i32 1
28 %b6 = getelementptr [50 x %struct.data]* @in2, i64 0, i64 %indvar7, i32 1
29 %b = getelementptr [50 x %struct.data]* @in1, i64 0, i64 %indvar7, i32 1
30 %exitcond9 = icmp ne i64 %indvar7, 50
31 br i1 %exitcond9, label %for.body, label %for.end
33 for.body: ; preds = %for.cond
34 %tmp2 = load i16* %b, align 2
35 %tmp7 = load i16* %b6, align 2
36 %cmp11 = icmp slt i16 %tmp2, %tmp7
37 br i1 %cmp11, label %if.else, label %if.then
39 if.then: ; preds = %for.body
40 store i16 %tmp2, i16* %b17, align 2
41 %add = add i16 %tmp7, 5
42 store i16 %add, i16* %a, align 4
45 if.else: ; preds = %for.body
46 %sub = add i16 %tmp7, -12
47 store i16 %sub, i16* %b17, align 2
48 %add35 = add i16 %tmp2, %tmp7
49 store i16 %add35, i16* %a, align 4
52 if.end: ; preds = %if.else, %if.then
55 for.inc: ; preds = %if.end
56 %indvar.next8 = add i64 %indvar7, 1
59 for.end: ; preds = %for.cond
62 for.cond42: ; preds = %for.inc79, %for.end
63 %indvar = phi i64 [ %indvar.next, %for.inc79 ], [ 0, %for.end ]
64 %arrayidx77 = getelementptr [50 x i16]* @out2, i64 0, i64 %indvar
65 %arrayidx67 = getelementptr [50 x i16]* @out1, i64 0, i64 %indvar
66 %b55 = getelementptr [50 x %struct.data]* @in2, i64 0, i64 %indvar, i32 1
67 %b50 = getelementptr [50 x %struct.data]* @in1, i64 0, i64 %indvar, i32 1
68 %exitcond = icmp ne i64 %indvar, 50
69 br i1 %exitcond, label %for.body46, label %for.end82
71 for.body46: ; preds = %for.cond42
72 %tmp51 = load i16* %b50, align 2
73 %tmp56 = load i16* %b55, align 2
74 %cmp61 = icmp slt i16 %tmp51, %tmp56
75 br i1 %cmp61, label %if.else68, label %if.then63
77 if.then63: ; preds = %for.body46
78 store i16 %tmp51, i16* %arrayidx67, align 2
81 if.else68: ; preds = %for.body46
82 %add73 = add i16 %tmp51, %tmp56
83 store i16 %add73, i16* %arrayidx77, align 2
86 if.end78: ; preds = %if.else68, %if.then63
89 for.inc79: ; preds = %if.end78
90 %indvar.next = add i64 %indvar, 1
93 for.end82: ; preds = %for.cond42
97 define i32 @main() nounwind uwtable {
99 call void @check_vect()
102 for.cond: ; preds = %for.inc, %entry
103 %indvar5 = phi i64 [ %indvar.next6, %for.inc ], [ 0, %entry ]
104 %b18 = getelementptr [50 x %struct.data]* @in2, i64 0, i64 %indvar5, i32 1
105 %tmp8 = add i64 %indvar5, 5
106 %conv14 = trunc i64 %tmp8 to i16
107 %scevgep10 = getelementptr [50 x %struct.data]* @in2, i64 0, i64 %indvar5
108 %a11 = bitcast %struct.data* %scevgep10 to i16*
109 %b = getelementptr [50 x %struct.data]* @in1, i64 0, i64 %indvar5, i32 1
110 %tmp13 = add i64 %indvar5, 2
111 %conv4 = trunc i64 %tmp13 to i16
112 %scevgep15 = getelementptr [50 x %struct.data]* @in1, i64 0, i64 %indvar5
113 %a = bitcast %struct.data* %scevgep15 to i16*
114 %conv = trunc i64 %indvar5 to i16
115 %exitcond = icmp ne i64 %indvar5, 50
116 br i1 %exitcond, label %for.body, label %for.end
118 for.body: ; preds = %for.cond
119 store i16 %conv, i16* %a, align 4
120 store i16 %conv4, i16* %b, align 2
121 store i16 5, i16* %a11, align 4
122 store i16 %conv14, i16* %b18, align 2
123 call void asm sideeffect "", "~{dirflag},~{fpsr},~{flags}"() nounwind, !srcloc !0
126 for.inc: ; preds = %for.body
127 %indvar.next6 = add i64 %indvar5, 1
130 for.end: ; preds = %for.cond
134 for.cond20: ; preds = %for.inc53, %for.end
135 %indvar = phi i64 [ %indvar.next, %for.inc53 ], [ 0, %for.end ]
136 %tmp = mul i64 %indvar, 2
137 %tmp2 = add i64 %tmp, 1
138 %arrayidx48 = getelementptr [100 x i16]* @result, i64 0, i64 %tmp2
139 %arrayidx33 = getelementptr [100 x i16]* @result, i64 0, i64 %tmp
140 %b41 = getelementptr [50 x %struct.data]* @out, i64 0, i64 %indvar, i32 1
141 %scevgep = getelementptr [50 x %struct.data]* @out, i64 0, i64 %indvar
142 %a28 = bitcast %struct.data* %scevgep to i16*
143 %i.1 = trunc i64 %indvar to i32
144 %cmp22 = icmp slt i32 %i.1, 50
145 br i1 %cmp22, label %for.body24, label %for.end56
147 for.body24: ; preds = %for.cond20
148 %tmp29 = load i16* %a28, align 4
149 %tmp34 = load i16* %arrayidx33, align 4
150 %cmp36 = icmp eq i16 %tmp29, %tmp34
151 br i1 %cmp36, label %lor.lhs.false, label %if.then
153 lor.lhs.false: ; preds = %for.body24
154 %tmp42 = load i16* %b41, align 2
155 %tmp49 = load i16* %arrayidx48, align 2
156 %cmp51 = icmp eq i16 %tmp42, %tmp49
157 br i1 %cmp51, label %if.end, label %if.then
159 if.then: ; preds = %lor.lhs.false, %for.body24
160 call void @abort() noreturn nounwind
163 if.end: ; preds = %lor.lhs.false
166 for.inc53: ; preds = %if.end
167 %indvar.next = add i64 %indvar, 1
170 for.end56: ; preds = %for.cond20
174 define internal void @check_vect() nounwind uwtable noinline {
176 %a = alloca i32, align 4
177 %b = alloca i32, align 4
178 %c = alloca i32, align 4
179 %d = alloca i32, align 4
180 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
181 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
182 %tobool = icmp eq i32 %call1, 0
183 br i1 %tobool, label %if.then, label %lor.lhs.false
185 lor.lhs.false: ; preds = %entry
186 %tmp4 = load i32* %d, align 4
187 %and6 = and i32 %tmp4, 67108864
188 %cmp = icmp eq i32 %and6, 0
189 br i1 %cmp, label %if.then, label %if.end
191 if.then: ; preds = %entry, %lor.lhs.false
192 call void @exit(i32 0) noreturn nounwind
195 if.end: ; preds = %lor.lhs.false
196 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
200 declare void @abort() noreturn
202 declare void (i32)* @signal(i32, void (i32)*) nounwind
204 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
206 call void @exit(i32 0) noreturn nounwind
209 return: ; No predecessors!
213 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
215 %and = and i32 %__level, -2147483648
216 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
217 %cmp = icmp ult i32 %call, %__level
218 br i1 %cmp, label %if.then, label %if.end
220 if.then: ; preds = %entry
223 if.end: ; preds = %entry
224 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !1
225 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
226 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
227 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
228 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
229 store i32 %asmresult, i32* %__eax, align 4
230 store i32 %asmresult8, i32* %__ebx, align 4
231 store i32 %asmresult9, i32* %__ecx, align 4
232 store i32 %asmresult10, i32* %__edx, align 4
235 return: ; preds = %if.end, %if.then
236 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
240 declare void @exit(i32) noreturn
242 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
244 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !2
245 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
246 %tobool = icmp eq i32* %__sig, null
247 br i1 %tobool, label %if.end, label %if.then
249 if.then: ; preds = %entry
250 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
251 store i32 %asmresult1, i32* %__sig, align 4
254 if.end: ; preds = %entry, %if.then
258 !0 = metadata !{i32 1319}
259 !1 = metadata !{i32 -2147342672, i32 -2147342664}
260 !2 = metadata !{i32 -2147342795, i32 -2147342787}