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 trapv-vect-reduc-4.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer trapv-vect-reduc-4.s > trapv-vect-reduc-4.ll
6 ; ModuleID = 'trapv-vect-reduc-4.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 @main1.b = internal unnamed_addr constant [16 x i32] [i32 0, i32 3, i32 6, i32 9, i32 12, i32 15, i32 18, i32 21, i32 24, i32 27, i32 30, i32 33, i32 36, i32 39, i32 42, i32 45], align 16
11 @main1.c = internal unnamed_addr constant [16 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15], align 16
13 define i32 @main1(i32 %x, i32 %max_result) nounwind uwtable {
15 %b = alloca [16 x i32], align 16
16 %c = alloca [16 x i32], align 16
17 %tmp = bitcast [16 x i32]* %b to i8*
18 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp, i8* bitcast ([16 x i32]* @main1.b to i8*), i64 64, i32 16, i1 false)
19 %tmp2 = bitcast [16 x i32]* %c to i8*
20 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp2, i8* bitcast ([16 x i32]* @main1.c to i8*), i64 64, i32 16, i1 false)
23 for.cond: ; preds = %for.inc, %entry
24 %indvar6 = phi i64 [ %indvar.next7, %for.inc ], [ 0, %entry ]
25 %diff.0 = phi i32 [ 2, %entry ], [ %add, %for.inc ]
26 %arrayidx12 = getelementptr [16 x i32]* %c, i64 0, i64 %indvar6
27 %arrayidx = getelementptr [16 x i32]* %b, i64 0, i64 %indvar6
28 %exitcond8 = icmp ne i64 %indvar6, 16
29 br i1 %exitcond8, label %for.body, label %for.end
31 for.body: ; preds = %for.cond
34 for.inc: ; preds = %for.body
35 %tmp13 = load i32* %arrayidx12, align 4
36 %tmp9 = load i32* %arrayidx, align 4
37 %sub = sub nsw i32 %tmp9, %tmp13
38 %add = add nsw i32 %diff.0, %sub
39 %indvar.next7 = add i64 %indvar6, 1
42 for.end: ; preds = %for.cond
43 %diff.0.lcssa = phi i32 [ %diff.0, %for.cond ]
46 for.cond16: ; preds = %for.inc31, %for.end
47 %indvar2 = phi i64 [ %indvar.next3, %for.inc31 ], [ 0, %for.end ]
48 %max.0 = phi i32 [ %x, %for.end ], [ %cond, %for.inc31 ]
49 %arrayidx23 = getelementptr [16 x i32]* %c, i64 0, i64 %indvar2
50 %exitcond4 = icmp ne i64 %indvar2, 16
51 br i1 %exitcond4, label %for.body19, label %for.end34
53 for.body19: ; preds = %for.cond16
54 %tmp24 = load i32* %arrayidx23, align 4
55 %cmp25 = icmp slt i32 %max.0, %tmp24
56 br i1 %cmp25, label %cond.true, label %cond.false
58 cond.true: ; preds = %for.body19
59 %tmp29 = load i32* %arrayidx23, align 4
62 cond.false: ; preds = %for.body19
65 cond.end: ; preds = %cond.false, %cond.true
66 %cond = phi i32 [ %tmp29, %cond.true ], [ %max.0, %cond.false ]
69 for.inc31: ; preds = %cond.end
70 %indvar.next3 = add i64 %indvar2, 1
73 for.end34: ; preds = %for.cond16
74 %max.0.lcssa = phi i32 [ %max.0, %for.cond16 ]
77 for.cond35: ; preds = %for.inc54, %for.end34
78 %indvar = phi i64 [ %indvar.next, %for.inc54 ], [ 0, %for.end34 ]
79 %min.0 = phi i32 [ 10, %for.end34 ], [ %cond53, %for.inc54 ]
80 %arrayidx42 = getelementptr [16 x i32]* %c, i64 0, i64 %indvar
81 %exitcond = icmp ne i64 %indvar, 16
82 br i1 %exitcond, label %for.body38, label %for.end57
84 for.body38: ; preds = %for.cond35
85 %tmp43 = load i32* %arrayidx42, align 4
86 %cmp44 = icmp sgt i32 %min.0, %tmp43
87 br i1 %cmp44, label %cond.true45, label %cond.false50
89 cond.true45: ; preds = %for.body38
90 %tmp49 = load i32* %arrayidx42, align 4
93 cond.false50: ; preds = %for.body38
96 cond.end52: ; preds = %cond.false50, %cond.true45
97 %cond53 = phi i32 [ %tmp49, %cond.true45 ], [ %min.0, %cond.false50 ]
100 for.inc54: ; preds = %cond.end52
101 %indvar.next = add i64 %indvar, 1
104 for.end57: ; preds = %for.cond35
105 %min.0.lcssa = phi i32 [ %min.0, %for.cond35 ]
106 %cmp59 = icmp eq i32 %diff.0.lcssa, 242
107 br i1 %cmp59, label %if.end, label %if.then
109 if.then: ; preds = %for.end57
110 call void @abort() noreturn nounwind
113 if.end: ; preds = %for.end57
114 %cmp62 = icmp eq i32 %max.0.lcssa, %max_result
115 br i1 %cmp62, label %if.end64, label %if.then63
117 if.then63: ; preds = %if.end
118 call void @abort() noreturn nounwind
121 if.end64: ; preds = %if.end
122 %cmp66 = icmp eq i32 %min.0.lcssa, 0
123 br i1 %cmp66, label %if.end68, label %if.then67
125 if.then67: ; preds = %if.end64
126 call void @abort() noreturn nounwind
129 if.end68: ; preds = %if.end64
133 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
135 declare void @abort() noreturn
137 define i32 @main() nounwind uwtable {
139 call void @check_vect()
140 %call = call i32 @main1(i32 100, i32 100)
141 %call1 = call i32 @main1(i32 0, i32 15)
145 define internal void @check_vect() nounwind uwtable noinline {
147 %a = alloca i32, align 4
148 %b = alloca i32, align 4
149 %c = alloca i32, align 4
150 %d = alloca i32, align 4
151 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
152 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
153 %tobool = icmp eq i32 %call1, 0
154 br i1 %tobool, label %if.then, label %lor.lhs.false
156 lor.lhs.false: ; preds = %entry
157 %tmp4 = load i32* %d, align 4
158 %and6 = and i32 %tmp4, 67108864
159 %cmp = icmp eq i32 %and6, 0
160 br i1 %cmp, label %if.then, label %if.end
162 if.then: ; preds = %entry, %lor.lhs.false
163 call void @exit(i32 0) noreturn nounwind
166 if.end: ; preds = %lor.lhs.false
167 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
171 declare void (i32)* @signal(i32, void (i32)*) nounwind
173 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
175 call void @exit(i32 0) noreturn nounwind
178 return: ; No predecessors!
182 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
184 %and = and i32 %__level, -2147483648
185 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
186 %cmp = icmp ult i32 %call, %__level
187 br i1 %cmp, label %if.then, label %if.end
189 if.then: ; preds = %entry
192 if.end: ; preds = %entry
193 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
194 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
195 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
196 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
197 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
198 store i32 %asmresult, i32* %__eax, align 4
199 store i32 %asmresult8, i32* %__ebx, align 4
200 store i32 %asmresult9, i32* %__ecx, align 4
201 store i32 %asmresult10, i32* %__edx, align 4
204 return: ; preds = %if.end, %if.then
205 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
209 declare void @exit(i32) noreturn
211 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
213 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
214 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
215 %tobool = icmp eq i32* %__sig, null
216 br i1 %tobool, label %if.end, label %if.then
218 if.then: ; preds = %entry
219 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
220 store i32 %asmresult1, i32* %__sig, align 4
223 if.end: ; preds = %entry, %if.then
227 !0 = metadata !{i32 -2147343429, i32 -2147343421}
228 !1 = metadata !{i32 -2147343552, i32 -2147343544}