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-2char.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-reduc-2char.s > vect-reduc-2char.ll
6 ; ModuleID = 'vect-reduc-2char.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 i8] c"\01\02\03\06\08\0A\0C\0E\10\12\14\16\18\1A\1C\1E", align 16
11 @main1.c = internal unnamed_addr constant [16 x i8] c"\01\01\02\03\04\05\06\07\08\09\0A\0B\0C\0D\0E\0F", align 16
13 define void @main1(i8 signext %x, i8 signext %max_result, i8 signext %min_result) nounwind uwtable noinline {
15 %b = alloca [16 x i8], align 16
16 %c = alloca [16 x i8], align 16
17 %tmp = getelementptr inbounds [16 x i8]* %b, i64 0, i64 0
18 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp, i8* getelementptr inbounds ([16 x i8]* @main1.b, i64 0, i64 0), i64 16, i32 16, i1 false)
19 %tmp2 = getelementptr inbounds [16 x i8]* %c, i64 0, i64 0
20 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp2, i8* getelementptr inbounds ([16 x i8]* @main1.c, i64 0, i64 0), i64 16, i32 16, i1 false)
23 for.cond: ; preds = %for.inc, %entry
24 %indvar9 = phi i64 [ %indvar.next10, %for.inc ], [ 0, %entry ]
25 %diff.0 = phi i32 [ 2, %entry ], [ %phitmp, %for.inc ]
26 %arrayidx13 = getelementptr [16 x i8]* %c, i64 0, i64 %indvar9
27 %arrayidx = getelementptr [16 x i8]* %b, i64 0, i64 %indvar9
28 %exitcond11 = icmp ne i64 %indvar9, 16
29 br i1 %exitcond11, label %for.body, label %for.end
31 for.body: ; preds = %for.cond
34 for.inc: ; preds = %for.body
35 %tmp14 = load i8* %arrayidx13, align 1
36 %tmp10 = load i8* %arrayidx, align 1
37 %conv153 = zext i8 %tmp14 to i32
38 %conv2 = zext i8 %tmp10 to i32
39 %sub = sub nsw i32 %conv2, %conv153
40 %add = add nsw i32 %diff.0, %sub
41 %sext = shl i32 %add, 24
42 %phitmp = ashr exact i32 %sext, 24
43 %indvar.next10 = add i64 %indvar9, 1
46 for.end: ; preds = %for.cond
47 %diff.0.lcssa = phi i32 [ %diff.0, %for.cond ]
50 for.cond22: ; preds = %for.inc44, %for.end
51 %indvar5 = phi i64 [ %indvar.next6, %for.inc44 ], [ 0, %for.end ]
52 %max.0 = phi i8 [ %x, %for.end ], [ %cond.in, %for.inc44 ]
53 %arrayidx31 = getelementptr [16 x i8]* %c, i64 0, i64 %indvar5
54 %exitcond7 = icmp ne i64 %indvar5, 16
55 br i1 %exitcond7, label %for.body26, label %for.end47
57 for.body26: ; preds = %for.cond22
58 %tmp32 = load i8* %arrayidx31, align 1
59 %cmp34 = icmp slt i8 %max.0, %tmp32
60 br i1 %cmp34, label %cond.true, label %cond.false
62 cond.true: ; preds = %for.body26
63 %tmp39 = load i8* %arrayidx31, align 1
66 cond.false: ; preds = %for.body26
69 cond.end: ; preds = %cond.false, %cond.true
70 %cond.in = phi i8 [ %tmp39, %cond.true ], [ %max.0, %cond.false ]
73 for.inc44: ; preds = %cond.end
74 %indvar.next6 = add i64 %indvar5, 1
77 for.end47: ; preds = %for.cond22
78 %max.0.lcssa = phi i8 [ %max.0, %for.cond22 ]
81 for.cond48: ; preds = %for.inc74, %for.end47
82 %indvar = phi i64 [ %indvar.next, %for.inc74 ], [ 0, %for.end47 ]
83 %min.0 = phi i8 [ %x, %for.end47 ], [ %cond72.in, %for.inc74 ]
84 %arrayidx57 = getelementptr [16 x i8]* %c, i64 0, i64 %indvar
85 %exitcond = icmp ne i64 %indvar, 16
86 br i1 %exitcond, label %for.body52, label %for.end77
88 for.body52: ; preds = %for.cond48
89 %tmp58 = load i8* %arrayidx57, align 1
90 %cmp60 = icmp sgt i8 %min.0, %tmp58
91 br i1 %cmp60, label %cond.true62, label %cond.false68
93 cond.true62: ; preds = %for.body52
94 %tmp66 = load i8* %arrayidx57, align 1
97 cond.false68: ; preds = %for.body52
100 cond.end71: ; preds = %cond.false68, %cond.true62
101 %cond72.in = phi i8 [ %tmp66, %cond.true62 ], [ %min.0, %cond.false68 ]
104 for.inc74: ; preds = %cond.end71
105 %indvar.next = add i64 %indvar, 1
108 for.end77: ; preds = %for.cond48
109 %min.0.lcssa = phi i8 [ %min.0, %for.cond48 ]
110 %cmp80 = icmp eq i32 %diff.0.lcssa, 121
111 br i1 %cmp80, label %if.end, label %if.then
113 if.then: ; preds = %for.end77
114 call void @abort() noreturn nounwind
117 if.end: ; preds = %for.end77
118 %cmp86 = icmp eq i8 %max.0.lcssa, %max_result
119 br i1 %cmp86, label %if.end89, label %if.then88
121 if.then88: ; preds = %if.end
122 call void @abort() noreturn nounwind
125 if.end89: ; preds = %if.end
126 %cmp94 = icmp eq i8 %min.0.lcssa, %min_result
127 br i1 %cmp94, label %if.end97, label %if.then96
129 if.then96: ; preds = %if.end89
130 call void @abort() noreturn nounwind
133 if.end97: ; preds = %if.end89
137 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
139 declare void @abort() noreturn
141 define i32 @main() nounwind uwtable {
143 call void @check_vect()
144 call void @main1(i8 signext 100, i8 signext 100, i8 signext 1)
145 call void @main1(i8 signext 0, i8 signext 15, i8 signext 0)
149 define internal void @check_vect() nounwind uwtable noinline {
151 %a = alloca i32, align 4
152 %b = alloca i32, align 4
153 %c = alloca i32, align 4
154 %d = alloca i32, align 4
155 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
156 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
157 %tobool = icmp eq i32 %call1, 0
158 br i1 %tobool, label %if.then, label %lor.lhs.false
160 lor.lhs.false: ; preds = %entry
161 %tmp4 = load i32* %d, align 4
162 %and6 = and i32 %tmp4, 67108864
163 %cmp = icmp eq i32 %and6, 0
164 br i1 %cmp, label %if.then, label %if.end
166 if.then: ; preds = %entry, %lor.lhs.false
167 call void @exit(i32 0) noreturn nounwind
170 if.end: ; preds = %lor.lhs.false
171 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
175 declare void (i32)* @signal(i32, void (i32)*) nounwind
177 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
179 call void @exit(i32 0) noreturn nounwind
182 return: ; No predecessors!
186 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
188 %and = and i32 %__level, -2147483648
189 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
190 %cmp = icmp ult i32 %call, %__level
191 br i1 %cmp, label %if.then, label %if.end
193 if.then: ; preds = %entry
196 if.end: ; preds = %entry
197 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
198 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
199 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
200 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
201 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
202 store i32 %asmresult, i32* %__eax, align 4
203 store i32 %asmresult8, i32* %__ebx, align 4
204 store i32 %asmresult9, i32* %__ecx, align 4
205 store i32 %asmresult10, i32* %__edx, align 4
208 return: ; preds = %if.end, %if.then
209 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
213 declare void @exit(i32) noreturn
215 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
217 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
218 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
219 %tobool = icmp eq i32* %__sig, null
220 br i1 %tobool, label %if.end, label %if.then
222 if.then: ; preds = %entry
223 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
224 store i32 %asmresult1, i32* %__sig, align 4
227 if.end: ; preds = %entry, %if.then
231 !0 = metadata !{i32 -2147343303, i32 -2147343295}
232 !1 = metadata !{i32 -2147343426, i32 -2147343418}