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 wrapv-vect-reduc-2char.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer wrapv-vect-reduc-2char.s > wrapv-vect-reduc-2char.ll
6 ; ModuleID = 'wrapv-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 @b = global [16 x i8] c"\01\02\03\06\08\0A\0C\0E\10\12\14\16\18\1A\1C\1E", align 16
11 @c = global [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 {
17 for.cond: ; preds = %for.inc, %entry
18 %indvar7 = phi i64 [ %indvar.next8, %for.inc ], [ 0, %entry ]
19 %diff.0 = phi i32 [ 2, %entry ], [ %phitmp, %for.inc ]
20 %arrayidx8 = getelementptr [16 x i8]* @c, i64 0, i64 %indvar7
21 %arrayidx = getelementptr [16 x i8]* @b, i64 0, i64 %indvar7
22 %exitcond9 = icmp ne i64 %indvar7, 16
23 br i1 %exitcond9, label %for.body, label %for.end
25 for.body: ; preds = %for.cond
28 for.inc: ; preds = %for.body
29 %tmp9 = load i8* %arrayidx8, align 1
30 %tmp5 = load i8* %arrayidx, align 1
31 %conv103 = zext i8 %tmp9 to i32
32 %conv2 = zext i8 %tmp5 to i32
33 %sub = sub nsw i32 %conv2, %conv103
34 %add = add nsw i32 %diff.0, %sub
35 %sext = shl i32 %add, 24
36 %phitmp = ashr exact i32 %sext, 24
37 %indvar.next8 = add i64 %indvar7, 1
40 for.end: ; preds = %for.cond
41 %diff.0.lcssa = phi i32 [ %diff.0, %for.cond ]
44 for.cond17: ; preds = %for.inc39, %for.end
45 %indvar4 = phi i64 [ %indvar.next5, %for.inc39 ], [ 0, %for.end ]
46 %max.0 = phi i8 [ %x, %for.end ], [ %cond.in, %for.inc39 ]
47 %arrayidx26 = getelementptr [16 x i8]* @c, i64 0, i64 %indvar4
48 %exitcond6 = icmp ne i64 %indvar4, 16
49 br i1 %exitcond6, label %for.body21, label %for.end42
51 for.body21: ; preds = %for.cond17
52 %tmp27 = load i8* %arrayidx26, align 1
53 %cmp29 = icmp slt i8 %max.0, %tmp27
54 br i1 %cmp29, label %cond.true, label %cond.false
56 cond.true: ; preds = %for.body21
57 %tmp34 = load i8* %arrayidx26, align 1
60 cond.false: ; preds = %for.body21
63 cond.end: ; preds = %cond.false, %cond.true
64 %cond.in = phi i8 [ %tmp34, %cond.true ], [ %max.0, %cond.false ]
67 for.inc39: ; preds = %cond.end
68 %indvar.next5 = add i64 %indvar4, 1
71 for.end42: ; preds = %for.cond17
72 %max.0.lcssa = phi i8 [ %max.0, %for.cond17 ]
75 for.cond43: ; preds = %for.inc69, %for.end42
76 %indvar = phi i64 [ %indvar.next, %for.inc69 ], [ 0, %for.end42 ]
77 %min.0 = phi i8 [ %x, %for.end42 ], [ %cond67.in, %for.inc69 ]
78 %arrayidx52 = getelementptr [16 x i8]* @c, i64 0, i64 %indvar
79 %exitcond = icmp ne i64 %indvar, 16
80 br i1 %exitcond, label %for.body47, label %for.end72
82 for.body47: ; preds = %for.cond43
83 %tmp53 = load i8* %arrayidx52, align 1
84 %cmp55 = icmp sgt i8 %min.0, %tmp53
85 br i1 %cmp55, label %cond.true57, label %cond.false63
87 cond.true57: ; preds = %for.body47
88 %tmp61 = load i8* %arrayidx52, align 1
91 cond.false63: ; preds = %for.body47
94 cond.end66: ; preds = %cond.false63, %cond.true57
95 %cond67.in = phi i8 [ %tmp61, %cond.true57 ], [ %min.0, %cond.false63 ]
98 for.inc69: ; preds = %cond.end66
99 %indvar.next = add i64 %indvar, 1
102 for.end72: ; preds = %for.cond43
103 %min.0.lcssa = phi i8 [ %min.0, %for.cond43 ]
104 %cmp75 = icmp eq i32 %diff.0.lcssa, 121
105 br i1 %cmp75, label %if.end, label %if.then
107 if.then: ; preds = %for.end72
108 call void @abort() noreturn nounwind
111 if.end: ; preds = %for.end72
112 %cmp81 = icmp eq i8 %max.0.lcssa, %max_result
113 br i1 %cmp81, label %if.end84, label %if.then83
115 if.then83: ; preds = %if.end
116 call void @abort() noreturn nounwind
119 if.end84: ; preds = %if.end
120 %cmp89 = icmp eq i8 %min.0.lcssa, %min_result
121 br i1 %cmp89, label %if.end92, label %if.then91
123 if.then91: ; preds = %if.end84
124 call void @abort() noreturn nounwind
127 if.end92: ; preds = %if.end84
131 declare void @abort() noreturn
133 define i32 @main() nounwind uwtable {
135 call void @check_vect()
136 call void @main1(i8 signext 100, i8 signext 100, i8 signext 1)
137 call void @main1(i8 signext 0, i8 signext 15, i8 signext 0)
141 define internal void @check_vect() nounwind uwtable noinline {
143 %a = alloca i32, align 4
144 %b = alloca i32, align 4
145 %c = alloca i32, align 4
146 %d = alloca i32, align 4
147 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
148 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
149 %tobool = icmp eq i32 %call1, 0
150 br i1 %tobool, label %if.then, label %lor.lhs.false
152 lor.lhs.false: ; preds = %entry
153 %tmp4 = load i32* %d, align 4
154 %and6 = and i32 %tmp4, 67108864
155 %cmp = icmp eq i32 %and6, 0
156 br i1 %cmp, label %if.then, label %if.end
158 if.then: ; preds = %entry, %lor.lhs.false
159 call void @exit(i32 0) noreturn nounwind
162 if.end: ; preds = %lor.lhs.false
163 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
167 declare void (i32)* @signal(i32, void (i32)*) nounwind
169 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
171 call void @exit(i32 0) noreturn nounwind
174 return: ; No predecessors!
178 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
180 %and = and i32 %__level, -2147483648
181 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
182 %cmp = icmp ult i32 %call, %__level
183 br i1 %cmp, label %if.then, label %if.end
185 if.then: ; preds = %entry
188 if.end: ; preds = %entry
189 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
190 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
191 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
192 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
193 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
194 store i32 %asmresult, i32* %__eax, align 4
195 store i32 %asmresult8, i32* %__ebx, align 4
196 store i32 %asmresult9, i32* %__ecx, align 4
197 store i32 %asmresult10, i32* %__edx, align 4
200 return: ; preds = %if.end, %if.then
201 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
205 declare void @exit(i32) noreturn
207 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
209 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
210 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
211 %tobool = icmp eq i32* %__sig, null
212 br i1 %tobool, label %if.end, label %if.then
214 if.then: ; preds = %entry
215 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
216 store i32 %asmresult1, i32* %__sig, align 4
219 if.end: ; preds = %entry, %if.then
223 !0 = metadata !{i32 -2147343296, i32 -2147343288}
224 !1 = metadata !{i32 -2147343419, i32 -2147343411}