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-reduc-6.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-reduc-6.s > vect-reduc-6.ll
6 ; ModuleID = 'vect-reduc-6.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 float] [float 0.000000e+00, float 3.000000e+00, float 6.000000e+00, float 9.000000e+00, float 1.200000e+01, float 1.500000e+01, float 1.800000e+01, float 2.100000e+01, float 2.400000e+01, float 2.700000e+01, float 3.000000e+01, float 3.300000e+01, float 3.600000e+01, float 3.900000e+01, float 4.200000e+01, float 4.500000e+01], align 16
11 @main1.c = internal unnamed_addr constant [16 x float] [float 0.000000e+00, float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00, float 5.000000e+00, float 6.000000e+00, float 7.000000e+00, float 8.000000e+00, float 9.000000e+00, float 1.000000e+01, float 1.100000e+01, float 1.200000e+01, float 1.300000e+01, float 1.400000e+01, float 1.500000e+01], align 16
13 define i32 @main1(float %x, float %max_result) nounwind uwtable noinline {
15 %b = alloca [16 x float], align 16
16 %c = alloca [16 x float], align 16
17 %tmp = bitcast [16 x float]* %b to i8*
18 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp, i8* bitcast ([16 x float]* @main1.b to i8*), i64 64, i32 16, i1 false)
19 %tmp2 = bitcast [16 x float]* %c to i8*
20 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp2, i8* bitcast ([16 x float]* @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 float [ 2.000000e+00, %entry ], [ %add, %for.inc ]
26 %arrayidx12 = getelementptr [16 x float]* %c, i64 0, i64 %indvar6
27 %arrayidx = getelementptr [16 x float]* %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 float* %arrayidx12, align 4
36 %tmp9 = load float* %arrayidx, align 4
37 %sub = fsub float %tmp9, %tmp13
38 %add = fadd float %diff.0, %sub
39 %indvar.next7 = add i64 %indvar6, 1
42 for.end: ; preds = %for.cond
43 %diff.0.lcssa = phi float [ %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 float [ %x, %for.end ], [ %cond, %for.inc31 ]
49 %arrayidx23 = getelementptr [16 x float]* %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 float* %arrayidx23, align 4
55 %cmp25 = fcmp olt float %max.0, %tmp24
56 br i1 %cmp25, label %cond.true, label %cond.false
58 cond.true: ; preds = %for.body19
59 %tmp29 = load float* %arrayidx23, align 4
62 cond.false: ; preds = %for.body19
65 cond.end: ; preds = %cond.false, %cond.true
66 %cond = phi float [ %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 float [ %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 float [ 1.000000e+01, %for.end34 ], [ %cond53, %for.inc54 ]
80 %arrayidx42 = getelementptr [16 x float]* %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 float* %arrayidx42, align 4
86 %cmp44 = fcmp ogt float %min.0, %tmp43
87 br i1 %cmp44, label %cond.true45, label %cond.false50
89 cond.true45: ; preds = %for.body38
90 %tmp49 = load float* %arrayidx42, align 4
93 cond.false50: ; preds = %for.body38
96 cond.end52: ; preds = %cond.false50, %cond.true45
97 %cond53 = phi float [ %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 float [ %min.0, %for.cond35 ]
106 %cmp59 = fcmp une float %diff.0.lcssa, 2.420000e+02
107 br i1 %cmp59, label %if.then, label %if.end
109 if.then: ; preds = %for.end57
110 call void @abort() noreturn nounwind
113 if.end: ; preds = %for.end57
114 %cmp62 = fcmp une float %max.0.lcssa, %max_result
115 br i1 %cmp62, label %if.then63, label %if.end64
117 if.then63: ; preds = %if.end
118 call void @abort() noreturn nounwind
121 if.end64: ; preds = %if.end
122 %cmp66 = fcmp une float %min.0.lcssa, 0.000000e+00
123 br i1 %cmp66, label %if.then67, label %if.end68
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(float 1.000000e+02, float 1.000000e+02)
141 %call1 = call i32 @main1(float 0.000000e+00, float 1.500000e+01)
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 -2147343249, i32 -2147343241}
228 !1 = metadata !{i32 -2147343372, i32 -2147343364}