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-19.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer no-scevccp-outer-19.s > no-scevccp-outer-19.ll
6 ; ModuleID = 'no-scevccp-outer-19.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 [64 x i16] zeroinitializer, align 16
11 @b = common global [64 x i32] zeroinitializer, align 16
13 define i32 @foo() nounwind uwtable noinline {
17 for.cond: ; preds = %for.inc21, %entry
18 %indvar = phi i64 [ %indvar.next, %for.inc21 ], [ 0, %entry ]
19 %arrayidx20 = getelementptr [64 x i32]* @b, i64 0, i64 %indvar
20 %arrayidx = getelementptr [64 x i16]* @a, i64 0, i64 %indvar
21 %exitcond1 = icmp ne i64 %indvar, 64
22 br i1 %exitcond1, label %for.body, label %for.end24
24 for.body: ; preds = %for.cond
27 for.cond2: ; preds = %for.inc, %for.body
28 %tmp = phi i16 [ 0, %for.body ], [ %inc, %for.inc ]
29 %exitcond = icmp ne i16 %tmp, 64
30 br i1 %exitcond, label %for.body7, label %for.end
32 for.body7: ; preds = %for.cond2
35 for.inc: ; preds = %for.body7
36 %inc = add i16 %tmp, 1
39 for.end: ; preds = %for.cond2
40 store i16 2016, i16* %arrayidx, align 2
41 %conv17 = zext i16 2016 to i32
42 store i32 %conv17, i32* %arrayidx20, align 4
45 for.inc21: ; preds = %for.end
46 %indvar.next = add i64 %indvar, 1
49 for.end24: ; preds = %for.cond
53 define i32 @main() nounwind uwtable {
55 call void @check_vect()
58 for.cond: ; preds = %for.inc, %entry
59 %indvar1 = phi i64 [ %indvar.next2, %for.inc ], [ 0, %entry ]
60 %arrayidx = getelementptr [64 x i16]* @a, i64 0, i64 %indvar1
61 %conv = trunc i64 %indvar1 to i16
62 %exitcond3 = icmp ne i64 %indvar1, 64
63 br i1 %exitcond3, label %for.body, label %for.end
65 for.body: ; preds = %for.cond
66 store i16 %conv, i16* %arrayidx, align 2
69 for.inc: ; preds = %for.body
70 %indvar.next2 = add i64 %indvar1, 1
73 for.end: ; preds = %for.cond
74 %call = call i32 @foo()
77 for.cond4: ; preds = %for.inc39, %for.end
78 %indvar = phi i64 [ %indvar.next, %for.inc39 ], [ 0, %for.end ]
79 %arrayidx33 = getelementptr [64 x i32]* @b, i64 0, i64 %indvar
80 %arrayidx24 = getelementptr [64 x i16]* @a, i64 0, i64 %indvar
81 %i.1 = trunc i64 %indvar to i32
82 %cmp6 = icmp slt i32 %i.1, 64
83 br i1 %cmp6, label %for.body8, label %for.end42
85 for.body8: ; preds = %for.cond4
88 for.cond9: ; preds = %for.inc18, %for.body8
89 %tmp = phi i32 [ 0, %for.body8 ], [ %inc20, %for.inc18 ]
90 %sum.0 = phi i32 [ 0, %for.body8 ], [ %phitmp, %for.inc18 ]
91 %exitcond = icmp ne i32 %tmp, 64
92 br i1 %exitcond, label %for.body13, label %for.end21
94 for.body13: ; preds = %for.cond9
97 for.inc18: ; preds = %for.body13
98 %tmp4 = add nsw i32 %sum.0, %tmp
99 %inc20 = add nsw i32 %tmp, 1
100 %sext = shl i32 %tmp4, 16
101 %phitmp = ashr exact i32 %sext, 16
104 for.end21: ; preds = %for.cond9
105 %sum.0.lcssa = phi i32 [ %sum.0, %for.cond9 ]
106 %tmp25 = load i16* %arrayidx24, align 2
107 %conv26 = zext i16 %tmp25 to i32
108 %cmp29 = icmp eq i32 %conv26, %sum.0.lcssa
109 br i1 %cmp29, label %lor.lhs.false, label %if.then
111 lor.lhs.false: ; preds = %for.end21
112 %tmp34 = load i32* %arrayidx33, align 4
113 %cmp37 = icmp eq i32 %tmp34, %sum.0.lcssa
114 br i1 %cmp37, label %if.end, label %if.then
116 if.then: ; preds = %lor.lhs.false, %for.end21
117 call void @abort() noreturn nounwind
120 if.end: ; preds = %lor.lhs.false
123 for.inc39: ; preds = %if.end
124 %indvar.next = add i64 %indvar, 1
127 for.end42: ; preds = %for.cond4
131 define internal void @check_vect() nounwind uwtable noinline {
133 %a = alloca i32, align 4
134 %b = alloca i32, align 4
135 %c = alloca i32, align 4
136 %d = alloca i32, align 4
137 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
138 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
139 %tobool = icmp eq i32 %call1, 0
140 br i1 %tobool, label %if.then, label %lor.lhs.false
142 lor.lhs.false: ; preds = %entry
143 %tmp4 = load i32* %d, align 4
144 %and6 = and i32 %tmp4, 67108864
145 %cmp = icmp eq i32 %and6, 0
146 br i1 %cmp, label %if.then, label %if.end
148 if.then: ; preds = %entry, %lor.lhs.false
149 call void @exit(i32 0) noreturn nounwind
152 if.end: ; preds = %lor.lhs.false
153 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
157 declare void @abort() noreturn
159 declare void (i32)* @signal(i32, void (i32)*) nounwind
161 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
163 call void @exit(i32 0) noreturn nounwind
166 return: ; No predecessors!
170 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
172 %and = and i32 %__level, -2147483648
173 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
174 %cmp = icmp ult i32 %call, %__level
175 br i1 %cmp, label %if.then, label %if.end
177 if.then: ; preds = %entry
180 if.end: ; preds = %entry
181 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
182 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
183 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
184 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
185 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
186 store i32 %asmresult, i32* %__eax, align 4
187 store i32 %asmresult8, i32* %__ebx, align 4
188 store i32 %asmresult9, i32* %__ecx, align 4
189 store i32 %asmresult10, i32* %__edx, align 4
192 return: ; preds = %if.end, %if.then
193 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
197 declare void @exit(i32) noreturn
199 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
201 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
202 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
203 %tobool = icmp eq i32* %__sig, null
204 br i1 %tobool, label %if.end, label %if.then
206 if.then: ; preds = %entry
207 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
208 store i32 %asmresult1, i32* %__sig, align 4
211 if.end: ; preds = %entry, %if.then
215 !0 = metadata !{i32 -2147343469, i32 -2147343461}
216 !1 = metadata !{i32 -2147343592, i32 -2147343584}