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-6.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer slp-reduc-6.s > slp-reduc-6.ll
6 ; ModuleID = 'slp-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 @a = common global [128 x i32] zeroinitializer, align 16
11 @b = common global [128 x i32] zeroinitializer, align 16
13 define i32 @main1(i32 %n, i32 %res0, i32 %res1) nounwind uwtable noinline {
15 %tmp = icmp sgt i32 %n, 0
16 %smax = select i1 %tmp, i32 %n, i32 0
19 for.cond: ; preds = %for.inc, %entry
20 %tmp2 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
21 %sum0.0 = phi i32 [ 0, %entry ], [ %add11, %for.inc ]
22 %sum1.0 = phi i32 [ 0, %entry ], [ %add, %for.inc ]
23 %mul = mul i32 %tmp2, 2
24 %exitcond = icmp ne i32 %tmp2, %smax
25 br i1 %exitcond, label %for.body, label %for.end
27 for.body: ; preds = %for.cond
30 for.inc: ; preds = %for.body
31 %idxprom7 = sext i32 %mul to i64
32 %idxprom = sext i32 %mul to i64
33 %arrayidx8 = getelementptr inbounds [128 x i32]* @b, i64 0, i64 %idxprom7
34 %arrayidx = getelementptr inbounds [128 x i32]* @a, i64 0, i64 %idxprom
35 %tmp9 = load i32* %arrayidx8, align 8
36 %tmp3 = load i32* %arrayidx, align 8
37 %add11 = add nsw i32 %sum0.0, %tmp9
38 %add = add nsw i32 %sum1.0, %tmp3
39 %inc = add nsw i32 %tmp2, 1
42 for.end: ; preds = %for.cond
43 %sum1.0.lcssa = phi i32 [ %sum1.0, %for.cond ]
44 %sum0.0.lcssa = phi i32 [ %sum0.0, %for.cond ]
45 %cmp15 = icmp eq i32 %sum0.0.lcssa, %res0
46 br i1 %cmp15, label %lor.lhs.false, label %if.then
48 lor.lhs.false: ; preds = %for.end
49 %cmp18 = icmp eq i32 %sum1.0.lcssa, %res1
50 br i1 %cmp18, label %if.end, label %if.then
52 if.then: ; preds = %lor.lhs.false, %for.end
53 call void @abort() noreturn nounwind
56 if.end: ; preds = %lor.lhs.false
60 declare void @abort() noreturn
62 define i32 @main() nounwind uwtable {
64 call void @check_vect()
67 for.cond: ; preds = %for.inc, %entry
68 %indvar = phi i64 [ %indvar.next, %for.inc ], [ 0, %entry ]
69 %arrayidx5 = getelementptr [128 x i32]* @a, i64 0, i64 %indvar
70 %arrayidx = getelementptr [128 x i32]* @b, i64 0, i64 %indvar
71 %i.0 = trunc i64 %indvar to i32
72 %exitcond = icmp ne i64 %indvar, 128
73 br i1 %exitcond, label %for.body, label %for.end
75 for.body: ; preds = %for.cond
76 store i32 %i.0, i32* %arrayidx, align 4
77 store i32 %i.0, i32* %arrayidx5, align 4
80 for.inc: ; preds = %for.body
81 %indvar.next = add i64 %indvar, 1
84 for.end: ; preds = %for.cond
85 %call = call i32 @main1(i32 64, i32 4032, i32 4032)
89 define internal void @check_vect() nounwind uwtable noinline {
91 %a = alloca i32, align 4
92 %b = alloca i32, align 4
93 %c = alloca i32, align 4
94 %d = alloca i32, align 4
95 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
96 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
97 %tobool = icmp eq i32 %call1, 0
98 br i1 %tobool, label %if.then, label %lor.lhs.false
100 lor.lhs.false: ; preds = %entry
101 %tmp4 = load i32* %d, align 4
102 %and6 = and i32 %tmp4, 67108864
103 %cmp = icmp eq i32 %and6, 0
104 br i1 %cmp, label %if.then, label %if.end
106 if.then: ; preds = %entry, %lor.lhs.false
107 call void @exit(i32 0) noreturn nounwind
110 if.end: ; preds = %lor.lhs.false
111 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
115 declare void (i32)* @signal(i32, void (i32)*) nounwind
117 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
119 call void @exit(i32 0) noreturn nounwind
122 return: ; No predecessors!
126 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
128 %and = and i32 %__level, -2147483648
129 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
130 %cmp = icmp ult i32 %call, %__level
131 br i1 %cmp, label %if.then, label %if.end
133 if.then: ; preds = %entry
136 if.end: ; preds = %entry
137 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
138 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
139 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
140 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
141 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
142 store i32 %asmresult, i32* %__eax, align 4
143 store i32 %asmresult8, i32* %__ebx, align 4
144 store i32 %asmresult9, i32* %__ecx, align 4
145 store i32 %asmresult10, i32* %__edx, align 4
148 return: ; preds = %if.end, %if.then
149 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
153 declare void @exit(i32) noreturn
155 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
157 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
158 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
159 %tobool = icmp eq i32* %__sig, null
160 br i1 %tobool, label %if.end, label %if.then
162 if.then: ; preds = %entry
163 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
164 store i32 %asmresult1, i32* %__sig, align 4
167 if.end: ; preds = %entry, %if.then
171 !0 = metadata !{i32 -2147343227, i32 -2147343219}
172 !1 = metadata !{i32 -2147343350, i32 -2147343342}