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 slp-reduc-5.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer slp-reduc-5.s > slp-reduc-5.ll
6 ; ModuleID = 'slp-reduc-5.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 @c = common global [128 x i32] zeroinitializer, align 16
12 define i32 @main1(i32 %n, i32 %res0, i32 %res1) nounwind uwtable noinline {
14 %tmp = icmp sgt i32 %n, 0
15 %smax = select i1 %tmp, i32 %n, i32 0
18 for.cond: ; preds = %for.inc, %entry
19 %tmp6 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
20 %max0.0 = phi i32 [ -100, %entry ], [ %cond29, %for.inc ]
21 %max1.0 = phi i32 [ -313, %entry ], [ %cond, %for.inc ]
22 %mul15 = mul i32 %tmp6, 2
23 %add1 = add i32 %mul15, 1
24 %exitcond = icmp ne i32 %tmp6, %smax
25 br i1 %exitcond, label %for.body, label %for.end
27 for.body: ; preds = %for.cond
28 %idxprom = sext i32 %add1 to i64
29 %arrayidx = getelementptr inbounds [128 x i32]* @c, i64 0, i64 %idxprom
30 %tmp4 = load i32* %arrayidx, align 4
31 %cmp5 = icmp slt i32 %max1.0, %tmp4
32 br i1 %cmp5, label %cond.true, label %cond.false
34 cond.true: ; preds = %for.body
35 %idxprom9 = sext i32 %add1 to i64
36 %arrayidx10 = getelementptr inbounds [128 x i32]* @c, i64 0, i64 %idxprom9
37 %tmp11 = load i32* %arrayidx10, align 4
40 cond.false: ; preds = %for.body
43 cond.end: ; preds = %cond.false, %cond.true
44 %cond = phi i32 [ %tmp11, %cond.true ], [ %max1.0, %cond.false ]
45 %idxprom16 = sext i32 %mul15 to i64
46 %arrayidx17 = getelementptr inbounds [128 x i32]* @c, i64 0, i64 %idxprom16
47 %tmp18 = load i32* %arrayidx17, align 8
48 %cmp19 = icmp slt i32 %max0.0, %tmp18
49 br i1 %cmp19, label %cond.true20, label %cond.false26
51 cond.true20: ; preds = %cond.end
52 %idxprom23 = sext i32 %mul15 to i64
53 %arrayidx24 = getelementptr inbounds [128 x i32]* @c, i64 0, i64 %idxprom23
54 %tmp25 = load i32* %arrayidx24, align 8
57 cond.false26: ; preds = %cond.end
60 cond.end28: ; preds = %cond.false26, %cond.true20
61 %cond29 = phi i32 [ %tmp25, %cond.true20 ], [ %max0.0, %cond.false26 ]
64 for.inc: ; preds = %cond.end28
65 %inc = add nsw i32 %tmp6, 1
68 for.end: ; preds = %for.cond
69 %max1.0.lcssa = phi i32 [ %max1.0, %for.cond ]
70 %max0.0.lcssa = phi i32 [ %max0.0, %for.cond ]
71 %cmp33 = icmp eq i32 %max0.0.lcssa, %res0
72 br i1 %cmp33, label %lor.lhs.false, label %if.then
74 lor.lhs.false: ; preds = %for.end
75 %cmp36 = icmp eq i32 %max1.0.lcssa, %res1
76 br i1 %cmp36, label %if.end, label %if.then
78 if.then: ; preds = %lor.lhs.false, %for.end
79 call void @abort() noreturn nounwind
82 if.end: ; preds = %lor.lhs.false
86 declare void @abort() noreturn
88 define i32 @main() nounwind uwtable {
90 call void @check_vect()
93 for.cond: ; preds = %for.inc, %entry
94 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
95 %tmp = mul i64 %indvar, -1
96 %tmp1 = add i64 %tmp, -3
97 %mul = trunc i64 %tmp1 to i32
98 %arrayidx = getelementptr [128 x i32]* @c, i64 0, i64 %indvar
99 %exitcond = icmp ne i64 %indvar, 128
100 br i1 %exitcond, label %for.body, label %for.end
102 for.body: ; preds = %for.cond
103 store i32 %mul, i32* %arrayidx, align 4
106 for.inc: ; preds = %for.body
107 %indvar.next = add i64 %indvar, 1
110 for.end: ; preds = %for.cond
111 store i32 -100, i32* getelementptr inbounds ([128 x i32]* @c, i64 0, i64 1), align 4
112 store i32 -100, i32* getelementptr inbounds ([128 x i32]* @c, i64 0, i64 0), align 16
113 %call = call i32 @main1(i32 64, i32 -5, i32 -6)
117 define internal void @check_vect() nounwind uwtable noinline {
119 %a = alloca i32, align 4
120 %b = alloca i32, align 4
121 %c = alloca i32, align 4
122 %d = alloca i32, align 4
123 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
124 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
125 %tobool = icmp eq i32 %call1, 0
126 br i1 %tobool, label %if.then, label %lor.lhs.false
128 lor.lhs.false: ; preds = %entry
129 %tmp4 = load i32* %d, align 4
130 %and6 = and i32 %tmp4, 67108864
131 %cmp = icmp eq i32 %and6, 0
132 br i1 %cmp, label %if.then, label %if.end
134 if.then: ; preds = %entry, %lor.lhs.false
135 call void @exit(i32 0) noreturn nounwind
138 if.end: ; preds = %lor.lhs.false
139 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
143 declare void (i32)* @signal(i32, void (i32)*) nounwind
145 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
147 call void @exit(i32 0) noreturn nounwind
150 return: ; No predecessors!
154 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
156 %and = and i32 %__level, -2147483648
157 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
158 %cmp = icmp ult i32 %call, %__level
159 br i1 %cmp, label %if.then, label %if.end
161 if.then: ; preds = %entry
164 if.end: ; preds = %entry
165 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
166 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
167 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
168 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
169 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
170 store i32 %asmresult, i32* %__eax, align 4
171 store i32 %asmresult8, i32* %__ebx, align 4
172 store i32 %asmresult9, i32* %__ecx, align 4
173 store i32 %asmresult10, i32* %__edx, align 4
176 return: ; preds = %if.end, %if.then
177 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
181 declare void @exit(i32) noreturn
183 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
185 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
186 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
187 %tobool = icmp eq i32* %__sig, null
188 br i1 %tobool, label %if.end, label %if.then
190 if.then: ; preds = %entry
191 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
192 store i32 %asmresult1, i32* %__sig, align 4
195 if.end: ; preds = %entry, %if.then
199 !0 = metadata !{i32 -2147343406, i32 -2147343398}
200 !1 = metadata !{i32 -2147343529, i32 -2147343521}