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-1.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer slp-reduc-1.s > slp-reduc-1.ll
6 ; ModuleID = 'slp-reduc-1.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 @ub = global [16 x i32] [i32 0, i32 3, i32 6, i32 9, i32 12, i32 15, i32 18, i32 21, i32 24, i32 27, i32 30, i32 33, i32 36, i32 39, i32 42, i32 45], align 16
11 @uc = global [16 x i32] [i32 0, i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9, i32 10, i32 11, i32 12, i32 13, i32 14, i32 15], align 16
13 define i32 @main1(i32 %n, i32 %res0, i32 %res1, i32 %res2, i32 %res3) 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 %tmp12 = phi i32 [ 0, %entry ], [ %inc, %for.inc ]
21 %udiff0.0 = phi i32 [ 5, %entry ], [ %add54, %for.inc ]
22 %udiff1.0 = phi i32 [ 10, %entry ], [ %add41, %for.inc ]
23 %udiff2.0 = phi i32 [ 20, %entry ], [ %add26, %for.inc ]
24 %udiff3.0 = phi i32 [ 30, %entry ], [ %add11, %for.inc ]
25 %mul43 = mul i32 %tmp12, 4
26 %add295 = add i32 %mul43, 1
27 %add143 = add i32 %mul43, 2
28 %add1 = add i32 %mul43, 3
29 %exitcond = icmp ne i32 %tmp12, %smax
30 br i1 %exitcond, label %for.body, label %for.end
32 for.body: ; preds = %for.cond
35 for.inc: ; preds = %for.body
36 %idxprom49 = sext i32 %mul43 to i64
37 %idxprom44 = sext i32 %mul43 to i64
38 %idxprom36 = sext i32 %add295 to i64
39 %idxprom30 = sext i32 %add295 to i64
40 %idxprom21 = sext i32 %add143 to i64
41 %idxprom15 = sext i32 %add143 to i64
42 %idxprom7 = sext i32 %add1 to i64
43 %idxprom = sext i32 %add1 to i64
44 %arrayidx50 = getelementptr inbounds [16 x i32]* @uc, i64 0, i64 %idxprom49
45 %arrayidx45 = getelementptr inbounds [16 x i32]* @ub, i64 0, i64 %idxprom44
46 %arrayidx37 = getelementptr inbounds [16 x i32]* @uc, i64 0, i64 %idxprom36
47 %arrayidx31 = getelementptr inbounds [16 x i32]* @ub, i64 0, i64 %idxprom30
48 %arrayidx22 = getelementptr inbounds [16 x i32]* @uc, i64 0, i64 %idxprom21
49 %arrayidx16 = getelementptr inbounds [16 x i32]* @ub, i64 0, i64 %idxprom15
50 %arrayidx8 = getelementptr inbounds [16 x i32]* @uc, i64 0, i64 %idxprom7
51 %arrayidx = getelementptr inbounds [16 x i32]* @ub, i64 0, i64 %idxprom
52 %tmp51 = load i32* %arrayidx50, align 16
53 %tmp46 = load i32* %arrayidx45, align 16
54 %tmp38 = load i32* %arrayidx37, align 4
55 %tmp32 = load i32* %arrayidx31, align 4
56 %tmp23 = load i32* %arrayidx22, align 8
57 %tmp17 = load i32* %arrayidx16, align 8
58 %tmp9 = load i32* %arrayidx8, align 4
59 %tmp3 = load i32* %arrayidx, align 4
60 %sub52 = sub i32 %tmp46, %tmp51
61 %sub39 = sub i32 %tmp32, %tmp38
62 %sub24 = sub i32 %tmp17, %tmp23
63 %sub = sub i32 %tmp3, %tmp9
64 %add54 = add i32 %udiff0.0, %sub52
65 %add41 = add i32 %udiff1.0, %sub39
66 %add26 = add i32 %udiff2.0, %sub24
67 %add11 = add i32 %udiff3.0, %sub
68 %inc = add nsw i32 %tmp12, 1
71 for.end: ; preds = %for.cond
72 %udiff3.0.lcssa = phi i32 [ %udiff3.0, %for.cond ]
73 %udiff2.0.lcssa = phi i32 [ %udiff2.0, %for.cond ]
74 %udiff1.0.lcssa = phi i32 [ %udiff1.0, %for.cond ]
75 %udiff0.0.lcssa = phi i32 [ %udiff0.0, %for.cond ]
76 %cmp58 = icmp eq i32 %udiff0.0.lcssa, %res0
77 br i1 %cmp58, label %lor.lhs.false, label %if.then
79 lor.lhs.false: ; preds = %for.end
80 %cmp61 = icmp eq i32 %udiff1.0.lcssa, %res1
81 br i1 %cmp61, label %lor.lhs.false62, label %if.then
83 lor.lhs.false62: ; preds = %lor.lhs.false
84 %cmp65 = icmp eq i32 %udiff2.0.lcssa, %res2
85 br i1 %cmp65, label %lor.lhs.false66, label %if.then
87 lor.lhs.false66: ; preds = %lor.lhs.false62
88 %cmp69 = icmp eq i32 %udiff3.0.lcssa, %res3
89 br i1 %cmp69, label %if.end, label %if.then
91 if.then: ; preds = %lor.lhs.false66, %lor.lhs.false62, %lor.lhs.false, %for.end
92 call void @abort() noreturn nounwind
95 if.end: ; preds = %lor.lhs.false66
99 declare void @abort() noreturn
101 define i32 @main() nounwind uwtable {
103 call void @check_vect()
104 %call = call i32 @main1(i32 4, i32 53, i32 66, i32 84, i32 102)
105 %call1 = call i32 @main1(i32 3, i32 29, i32 40, i32 56, i32 72)
109 define internal void @check_vect() nounwind uwtable noinline {
111 %a = alloca i32, align 4
112 %b = alloca i32, align 4
113 %c = alloca i32, align 4
114 %d = alloca i32, align 4
115 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
116 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
117 %tobool = icmp eq i32 %call1, 0
118 br i1 %tobool, label %if.then, label %lor.lhs.false
120 lor.lhs.false: ; preds = %entry
121 %tmp4 = load i32* %d, align 4
122 %and6 = and i32 %tmp4, 67108864
123 %cmp = icmp eq i32 %and6, 0
124 br i1 %cmp, label %if.then, label %if.end
126 if.then: ; preds = %entry, %lor.lhs.false
127 call void @exit(i32 0) noreturn nounwind
130 if.end: ; preds = %lor.lhs.false
131 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
135 declare void (i32)* @signal(i32, void (i32)*) nounwind
137 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
139 call void @exit(i32 0) noreturn nounwind
142 return: ; No predecessors!
146 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
148 %and = and i32 %__level, -2147483648
149 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
150 %cmp = icmp ult i32 %call, %__level
151 br i1 %cmp, label %if.then, label %if.end
153 if.then: ; preds = %entry
156 if.end: ; preds = %entry
157 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
158 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
159 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
160 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
161 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
162 store i32 %asmresult, i32* %__eax, align 4
163 store i32 %asmresult8, i32* %__ebx, align 4
164 store i32 %asmresult9, i32* %__ecx, align 4
165 store i32 %asmresult10, i32* %__edx, align 4
168 return: ; preds = %if.end, %if.then
169 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
173 declare void @exit(i32) noreturn
175 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
177 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
178 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
179 %tobool = icmp eq i32* %__sig, null
180 br i1 %tobool, label %if.end, label %if.then
182 if.then: ; preds = %entry
183 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
184 store i32 %asmresult1, i32* %__sig, align 4
187 if.end: ; preds = %entry, %if.then
191 !0 = metadata !{i32 -2147343144, i32 -2147343136}
192 !1 = metadata !{i32 -2147343267, i32 -2147343259}