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-7.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-reduc-7.s > vect-reduc-7.ll
6 ; ModuleID = 'vect-reduc-7.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 @main.A = internal constant [32 x i8] c"\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F\10pqrstuvwxyz{|}~\7F", align 16
11 @main.B = internal constant [32 x i8] c"pqrstuvwxyz{|}~\7F\80\81\82\83\84\85\86\87\88\89\8A\8B\8C\8D\8E\8F", align 16
12 @main.C = internal constant [32 x i8] c"\FF\FE\FD\FC\FB\FA\F9\F8\09\0A\0B\0C\0D\0E\0F\10\80\81\82\83\84\85\86\87pqrstuvw", align 16
14 define void @testmax(i8* %c, i8 zeroext %init, i8 zeroext %result) nounwind uwtable noinline {
16 %lc = alloca [32 x i8], align 16
17 %arraydecay = getelementptr inbounds [32 x i8]* %lc, i64 0, i64 0
18 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %arraydecay, i8* %c, i64 32, i32 1, i1 false)
21 for.cond: ; preds = %for.inc, %entry
22 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
23 %accum.0 = phi i8 [ %init, %entry ], [ %cond.in, %for.inc ]
24 %arrayidx = getelementptr [32 x i8]* %lc, i64 0, i64 %indvar
25 %exitcond = icmp ne i64 %indvar, 32
26 br i1 %exitcond, label %for.body, label %for.end
28 for.body: ; preds = %for.cond
29 %tmp6 = load i8* %arrayidx, align 1
30 %cmp8 = icmp ult i8 %accum.0, %tmp6
31 br i1 %cmp8, label %cond.true, label %cond.false
33 cond.true: ; preds = %for.body
34 %tmp13 = load i8* %arrayidx, align 1
37 cond.false: ; preds = %for.body
40 cond.end: ; preds = %cond.false, %cond.true
41 %cond.in = phi i8 [ %tmp13, %cond.true ], [ %accum.0, %cond.false ]
44 for.inc: ; preds = %cond.end
45 %indvar.next = add i64 %indvar, 1
48 for.end: ; preds = %for.cond
49 %accum.0.lcssa = phi i8 [ %accum.0, %for.cond ]
50 %cmp23 = icmp eq i8 %accum.0.lcssa, %result
51 br i1 %cmp23, label %if.end, label %if.then
53 if.then: ; preds = %for.end
54 call void @abort() noreturn nounwind
57 if.end: ; preds = %for.end
61 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
63 declare void @abort() noreturn
65 define void @testmin(i8* %c, i8 zeroext %init, i8 zeroext %result) nounwind uwtable noinline {
67 %lc = alloca [32 x i8], align 16
68 %arraydecay = getelementptr inbounds [32 x i8]* %lc, i64 0, i64 0
69 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %arraydecay, i8* %c, i64 32, i32 1, i1 false)
72 for.cond: ; preds = %for.inc, %entry
73 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
74 %accum.0 = phi i8 [ %init, %entry ], [ %cond.in, %for.inc ]
75 %arrayidx = getelementptr [32 x i8]* %lc, i64 0, i64 %indvar
76 %exitcond = icmp ne i64 %indvar, 32
77 br i1 %exitcond, label %for.body, label %for.end
79 for.body: ; preds = %for.cond
80 %tmp6 = load i8* %arrayidx, align 1
81 %cmp8 = icmp ugt i8 %accum.0, %tmp6
82 br i1 %cmp8, label %cond.true, label %cond.false
84 cond.true: ; preds = %for.body
85 %tmp13 = load i8* %arrayidx, align 1
88 cond.false: ; preds = %for.body
91 cond.end: ; preds = %cond.false, %cond.true
92 %cond.in = phi i8 [ %tmp13, %cond.true ], [ %accum.0, %cond.false ]
95 for.inc: ; preds = %cond.end
96 %indvar.next = add i64 %indvar, 1
99 for.end: ; preds = %for.cond
100 %accum.0.lcssa = phi i8 [ %accum.0, %for.cond ]
101 %cmp23 = icmp eq i8 %accum.0.lcssa, %result
102 br i1 %cmp23, label %if.end, label %if.then
104 if.then: ; preds = %for.end
105 call void @abort() noreturn nounwind
108 if.end: ; preds = %for.end
112 define i32 @main() nounwind uwtable {
114 call void @check_vect()
115 call void @testmin(i8* getelementptr inbounds ([32 x i8]* @main.A, i64 0, i64 0), i8 zeroext 10, i8 zeroext 1)
116 call void @testmin(i8* getelementptr inbounds ([32 x i8]* @main.B, i64 0, i64 0), i8 zeroext 127, i8 zeroext 112)
117 call void @testmin(i8* getelementptr inbounds ([32 x i8]* @main.C, i64 0, i64 0), i8 zeroext 127, i8 zeroext 9)
118 call void @testmax(i8* getelementptr inbounds ([32 x i8]* @main.A, i64 0, i64 0), i8 zeroext 0, i8 zeroext 127)
119 call void @testmax(i8* getelementptr inbounds ([32 x i8]* @main.B, i64 0, i64 0), i8 zeroext 0, i8 zeroext -113)
120 call void @testmax(i8* getelementptr inbounds ([32 x i8]* @main.C, i64 0, i64 0), i8 zeroext 0, i8 zeroext -1)
124 define internal void @check_vect() nounwind uwtable noinline {
126 %a = alloca i32, align 4
127 %b = alloca i32, align 4
128 %c = alloca i32, align 4
129 %d = alloca i32, align 4
130 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
131 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
132 %tobool = icmp eq i32 %call1, 0
133 br i1 %tobool, label %if.then, label %lor.lhs.false
135 lor.lhs.false: ; preds = %entry
136 %tmp4 = load i32* %d, align 4
137 %and6 = and i32 %tmp4, 67108864
138 %cmp = icmp eq i32 %and6, 0
139 br i1 %cmp, label %if.then, label %if.end
141 if.then: ; preds = %entry, %lor.lhs.false
142 call void @exit(i32 0) noreturn nounwind
145 if.end: ; preds = %lor.lhs.false
146 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
150 declare void (i32)* @signal(i32, void (i32)*) nounwind
152 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
154 call void @exit(i32 0) noreturn nounwind
157 return: ; No predecessors!
161 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
163 %and = and i32 %__level, -2147483648
164 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
165 %cmp = icmp ult i32 %call, %__level
166 br i1 %cmp, label %if.then, label %if.end
168 if.then: ; preds = %entry
171 if.end: ; preds = %entry
172 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
173 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
174 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
175 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
176 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
177 store i32 %asmresult, i32* %__eax, align 4
178 store i32 %asmresult8, i32* %__ebx, align 4
179 store i32 %asmresult9, i32* %__ecx, align 4
180 store i32 %asmresult10, i32* %__edx, align 4
183 return: ; preds = %if.end, %if.then
184 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
188 declare void @exit(i32) noreturn
190 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
192 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
193 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
194 %tobool = icmp eq i32* %__sig, null
195 br i1 %tobool, label %if.end, label %if.then
197 if.then: ; preds = %entry
198 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
199 store i32 %asmresult1, i32* %__sig, align 4
202 if.end: ; preds = %entry, %if.then
206 !0 = metadata !{i32 -2147344721, i32 -2147344713}
207 !1 = metadata !{i32 -2147344844, i32 -2147344836}