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 no-scevccp-outer-7.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer no-scevccp-outer-7.s > no-scevccp-outer-7.ll
6 ; ModuleID = 'no-scevccp-outer-7.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 [16 x i16] zeroinitializer, align 16
11 @in = common global [16 x i16] zeroinitializer, align 16
12 @coef = common global [16 x i16] zeroinitializer, align 16
14 define i32 @foo(i16 signext %scale) nounwind uwtable noinline {
18 for.cond: ; preds = %for.inc28, %entry
19 %indvar = phi i64 [ %indvar.next, %for.inc28 ], [ 0, %entry ]
20 %sum.0 = phi i32 [ 0, %entry ], [ %add27, %for.inc28 ]
21 %arrayidx21 = getelementptr [16 x i16]* @coef, i64 0, i64 %indvar
22 %arrayidx16 = getelementptr [16 x i16]* @in, i64 0, i64 %indvar
23 %arrayidx = getelementptr [16 x i16]* @a, i64 0, i64 %indvar
24 %exitcond1 = icmp ne i64 %indvar, 16
25 br i1 %exitcond1, label %for.body, label %for.end31
27 for.body: ; preds = %for.cond
30 for.cond1: ; preds = %for.inc, %for.body
31 %tmp = phi i16 [ 0, %for.body ], [ %inc, %for.inc ]
32 %exitcond = icmp ne i16 %tmp, 16
33 br i1 %exitcond, label %for.body5, label %for.end
35 for.body5: ; preds = %for.cond1
38 for.inc: ; preds = %for.body5
39 %inc = add i16 %tmp, 1
42 for.end: ; preds = %for.cond1
43 store i16 120, i16* %arrayidx, align 2
46 for.inc28: ; preds = %for.end
47 %tmp22 = load i16* %arrayidx21, align 2
48 %tmp17 = load i16* %arrayidx16, align 2
49 %conv23 = zext i16 %tmp22 to i32
50 %conv18 = zext i16 %tmp17 to i32
51 %conv25 = sext i16 %scale to i32
52 %mul = mul i32 %conv18, %conv23
53 %shr = lshr i32 %mul, %conv25
54 %add27 = add i32 %sum.0, %shr
55 %indvar.next = add i64 %indvar, 1
58 for.end31: ; preds = %for.cond
59 %sum.0.lcssa = phi i32 [ %sum.0, %for.cond ]
63 define zeroext i16 @bar() nounwind uwtable {
67 for.cond: ; preds = %for.inc, %entry
68 %tmp = phi i16 [ 0, %entry ], [ %inc, %for.inc ]
69 %exitcond = icmp ne i16 %tmp, 16
70 br i1 %exitcond, label %for.body, label %for.end
72 for.body: ; preds = %for.cond
75 for.inc: ; preds = %for.body
76 %inc = add i16 %tmp, 1
79 for.end: ; preds = %for.cond
83 define i32 @main() nounwind uwtable {
85 call void @check_vect()
88 for.cond: ; preds = %for.inc, %entry
89 %indvar2 = phi i64 [ %indvar.next3, %for.inc ], [ 0, %entry ]
90 %tmp = mul i64 %indvar2, 2
91 %conv = trunc i64 %tmp to i16
92 %arrayidx7 = getelementptr [16 x i16]* @coef, i64 0, i64 %indvar2
93 %conv4 = trunc i64 %indvar2 to i16
94 %arrayidx = getelementptr [16 x i16]* @in, i64 0, i64 %indvar2
95 %exitcond = icmp ne i64 %indvar2, 16
96 br i1 %exitcond, label %for.body, label %for.end
98 for.body: ; preds = %for.cond
99 store i16 %conv, i16* %arrayidx, align 2
100 store i16 %conv4, i16* %arrayidx7, align 2
103 for.inc: ; preds = %for.body
104 %indvar.next3 = add i64 %indvar2, 1
107 for.end: ; preds = %for.cond
108 %call = call i32 @foo(i16 signext 2)
111 for.cond9: ; preds = %for.inc35, %for.end
112 %indvar = phi i64 [ %indvar.next, %for.inc35 ], [ 0, %for.end ]
113 %sum.0 = phi i32 [ 0, %for.end ], [ %add, %for.inc35 ]
114 %arrayidx30 = getelementptr [16 x i16]* @coef, i64 0, i64 %indvar
115 %arrayidx25 = getelementptr [16 x i16]* @in, i64 0, i64 %indvar
116 %arrayidx16 = getelementptr [16 x i16]* @a, i64 0, i64 %indvar
117 %i.1 = trunc i64 %indvar to i32
118 %cmp11 = icmp slt i32 %i.1, 16
119 br i1 %cmp11, label %for.body13, label %for.end38
121 for.body13: ; preds = %for.cond9
122 %tmp17 = load i16* %arrayidx16, align 2
123 %call19 = call zeroext i16 @bar()
124 %cmp21 = icmp eq i16 %tmp17, %call19
125 br i1 %cmp21, label %if.end, label %if.then
127 if.then: ; preds = %for.body13
128 call void @abort() noreturn nounwind
131 if.end: ; preds = %for.body13
134 for.inc35: ; preds = %if.end
135 %tmp31 = load i16* %arrayidx30, align 2
136 %tmp26 = load i16* %arrayidx25, align 2
137 %conv32 = zext i16 %tmp31 to i32
138 %conv27 = zext i16 %tmp26 to i32
139 %mul33 = mul i32 %conv27, %conv32
140 %shr = lshr i32 %mul33, 2
141 %add = add i32 %sum.0, %shr
142 %indvar.next = add i64 %indvar, 1
145 for.end38: ; preds = %for.cond9
146 %sum.0.lcssa = phi i32 [ %sum.0, %for.cond9 ]
147 %cmp41 = icmp eq i32 %call, %sum.0.lcssa
148 br i1 %cmp41, label %if.end44, label %if.then43
150 if.then43: ; preds = %for.end38
151 call void @abort() noreturn nounwind
154 if.end44: ; preds = %for.end38
158 define internal void @check_vect() nounwind uwtable noinline {
160 %a = alloca i32, align 4
161 %b = alloca i32, align 4
162 %c = alloca i32, align 4
163 %d = alloca i32, align 4
164 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
165 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
166 %tobool = icmp eq i32 %call1, 0
167 br i1 %tobool, label %if.then, label %lor.lhs.false
169 lor.lhs.false: ; preds = %entry
170 %tmp4 = load i32* %d, align 4
171 %and6 = and i32 %tmp4, 67108864
172 %cmp = icmp eq i32 %and6, 0
173 br i1 %cmp, label %if.then, label %if.end
175 if.then: ; preds = %entry, %lor.lhs.false
176 call void @exit(i32 0) noreturn nounwind
179 if.end: ; preds = %lor.lhs.false
180 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
184 declare void @abort() noreturn
186 declare void (i32)* @signal(i32, void (i32)*) nounwind
188 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
190 call void @exit(i32 0) noreturn nounwind
193 return: ; No predecessors!
197 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
199 %and = and i32 %__level, -2147483648
200 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
201 %cmp = icmp ult i32 %call, %__level
202 br i1 %cmp, label %if.then, label %if.end
204 if.then: ; preds = %entry
207 if.end: ; preds = %entry
208 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
209 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
210 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
211 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
212 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
213 store i32 %asmresult, i32* %__eax, align 4
214 store i32 %asmresult8, i32* %__ebx, align 4
215 store i32 %asmresult9, i32* %__ecx, align 4
216 store i32 %asmresult10, i32* %__edx, align 4
219 return: ; preds = %if.end, %if.then
220 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
224 declare void @exit(i32) noreturn
226 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
228 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
229 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
230 %tobool = icmp eq i32* %__sig, null
231 br i1 %tobool, label %if.end, label %if.then
233 if.then: ; preds = %entry
234 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
235 store i32 %asmresult1, i32* %__sig, align 4
238 if.end: ; preds = %entry, %if.then
242 !0 = metadata !{i32 -2147342987, i32 -2147342979}
243 !1 = metadata !{i32 -2147343110, i32 -2147343102}