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-10.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer no-scevccp-outer-10.s > no-scevccp-outer-10.ll
6 ; ModuleID = 'no-scevccp-outer-10.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 @b = common global [40 x i32] zeroinitializer, align 16
11 @a = common global [40 x i32] zeroinitializer, align 16
13 define i32 @foo(i32 %n) nounwind uwtable noinline {
15 %tmp = icmp sgt i32 %n, 0
16 %smax = select i1 %tmp, i32 %n, i32 0
17 %tmp3 = zext i32 %smax to i33
18 %tmp4 = add i32 %smax, -1
19 %tmp5 = zext i32 %tmp4 to i33
20 %tmp6 = mul i33 %tmp3, %tmp5
21 %tmp8 = lshr i33 %tmp6, 1
22 %tmp9 = trunc i33 %tmp8 to i32
25 for.cond: ; preds = %for.inc32, %entry
26 %indvar = phi i64 [ %indvar.next, %for.inc32 ], [ 0, %entry ]
27 %tmp11 = mul i64 %indvar, 2
28 %tmp12 = add i64 %tmp11, 1
29 %arrayidx31 = getelementptr [40 x i32]* @a, i64 0, i64 %tmp12
30 %arrayidx23 = getelementptr [40 x i32]* @a, i64 0, i64 %tmp11
31 %arrayidx6 = getelementptr [40 x i32]* @b, i64 0, i64 %tmp12
32 %arrayidx = getelementptr [40 x i32]* @b, i64 0, i64 %tmp11
33 %exitcond10 = icmp ne i64 %indvar, 20
34 br i1 %exitcond10, label %for.body, label %for.end35
36 for.body: ; preds = %for.cond
37 %tmp2 = load i32* %arrayidx, align 8
38 %tmp7 = load i32* %arrayidx6, align 4
41 for.cond8: ; preds = %for.inc, %for.body
42 %tmp14 = phi i32 [ 0, %for.body ], [ %inc, %for.inc ]
43 %exitcond = icmp ne i32 %tmp14, %smax
44 br i1 %exitcond, label %for.body12, label %for.end
46 for.body12: ; preds = %for.cond8
49 for.inc: ; preds = %for.body12
50 %inc = add nsw i32 %tmp14, 1
53 for.end: ; preds = %for.cond8
54 %add19 = add nsw i32 %tmp9, %tmp2
55 store i32 %add19, i32* %arrayidx23, align 8
56 %add26 = add nsw i32 %tmp9, %tmp7
57 store i32 %add26, i32* %arrayidx31, align 4
60 for.inc32: ; preds = %for.end
61 %indvar.next = add i64 %indvar, 1
64 for.end35: ; preds = %for.cond
68 define i32 @main() nounwind uwtable {
70 call void @check_vect()
73 for.cond: ; preds = %for.inc, %entry
74 %indvar5 = phi i64 [ %indvar.next6, %for.inc ], [ 0, %entry ]
75 %arrayidx = getelementptr [40 x i32]* @b, i64 0, i64 %indvar5
76 %i.0 = trunc i64 %indvar5 to i32
77 %exitcond7 = icmp ne i64 %indvar5, 40
78 br i1 %exitcond7, label %for.body, label %for.end
80 for.body: ; preds = %for.cond
81 store i32 %i.0, i32* %arrayidx, align 4
84 for.inc: ; preds = %for.body
85 %indvar.next6 = add i64 %indvar5, 1
88 for.end: ; preds = %for.cond
89 %call = call i32 @foo(i32 39)
92 for.cond4: ; preds = %for.inc45, %for.end
93 %indvar = phi i64 [ %indvar.next, %for.inc45 ], [ 0, %for.end ]
94 %tmp = mul i64 %indvar, 2
95 %tmp3 = add i64 %tmp, 1
96 %arrayidx41 = getelementptr [40 x i32]* @b, i64 0, i64 %tmp3
97 %arrayidx34 = getelementptr [40 x i32]* @a, i64 0, i64 %tmp3
98 %arrayidx26 = getelementptr [40 x i32]* @b, i64 0, i64 %tmp
99 %arrayidx20 = getelementptr [40 x i32]* @a, i64 0, i64 %tmp
100 %i.1 = trunc i64 %indvar to i32
101 %cmp6 = icmp slt i32 %i.1, 20
102 br i1 %cmp6, label %for.body7, label %for.end48
104 for.body7: ; preds = %for.cond4
107 for.cond8: ; preds = %for.inc14, %for.body7
108 %tmp9 = phi i32 [ 0, %for.body7 ], [ %inc16, %for.inc14 ]
109 %exitcond = icmp ne i32 %tmp9, 39
110 br i1 %exitcond, label %for.body11, label %for.end17
112 for.body11: ; preds = %for.cond8
115 for.inc14: ; preds = %for.body11
116 %inc16 = add nsw i32 %tmp9, 1
119 for.end17: ; preds = %for.cond8
120 %tmp21 = load i32* %arrayidx20, align 8
121 %tmp27 = load i32* %arrayidx26, align 8
122 %add28 = add nsw i32 741, %tmp27
123 %cmp29 = icmp eq i32 %tmp21, %add28
124 br i1 %cmp29, label %lor.lhs.false, label %if.then
126 lor.lhs.false: ; preds = %for.end17
127 %tmp35 = load i32* %arrayidx34, align 4
128 %tmp42 = load i32* %arrayidx41, align 4
129 %add43 = add nsw i32 741, %tmp42
130 %cmp44 = icmp eq i32 %tmp35, %add43
131 br i1 %cmp44, label %if.end, label %if.then
133 if.then: ; preds = %lor.lhs.false, %for.end17
134 call void @abort() noreturn nounwind
137 if.end: ; preds = %lor.lhs.false
140 for.inc45: ; preds = %if.end
141 %indvar.next = add i64 %indvar, 1
144 for.end48: ; preds = %for.cond4
148 define internal void @check_vect() nounwind uwtable noinline {
150 %a = alloca i32, align 4
151 %b = alloca i32, align 4
152 %c = alloca i32, align 4
153 %d = alloca i32, align 4
154 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
155 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
156 %tobool = icmp eq i32 %call1, 0
157 br i1 %tobool, label %if.then, label %lor.lhs.false
159 lor.lhs.false: ; preds = %entry
160 %tmp4 = load i32* %d, align 4
161 %and6 = and i32 %tmp4, 67108864
162 %cmp = icmp eq i32 %and6, 0
163 br i1 %cmp, label %if.then, label %if.end
165 if.then: ; preds = %entry, %lor.lhs.false
166 call void @exit(i32 0) noreturn nounwind
169 if.end: ; preds = %lor.lhs.false
170 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
174 declare void @abort() noreturn
176 declare void (i32)* @signal(i32, void (i32)*) nounwind
178 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
180 call void @exit(i32 0) noreturn nounwind
183 return: ; No predecessors!
187 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
189 %and = and i32 %__level, -2147483648
190 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
191 %cmp = icmp ult i32 %call, %__level
192 br i1 %cmp, label %if.then, label %if.end
194 if.then: ; preds = %entry
197 if.end: ; preds = %entry
198 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
199 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
200 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
201 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
202 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
203 store i32 %asmresult, i32* %__eax, align 4
204 store i32 %asmresult8, i32* %__ebx, align 4
205 store i32 %asmresult9, i32* %__ecx, align 4
206 store i32 %asmresult10, i32* %__edx, align 4
209 return: ; preds = %if.end, %if.then
210 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
214 declare void @exit(i32) noreturn
216 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
218 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
219 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
220 %tobool = icmp eq i32* %__sig, null
221 br i1 %tobool, label %if.end, label %if.then
223 if.then: ; preds = %entry
224 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
225 store i32 %asmresult1, i32* %__sig, align 4
228 if.end: ; preds = %entry, %if.then
232 !0 = metadata !{i32 -2147343465, i32 -2147343457}
233 !1 = metadata !{i32 -2147343588, i32 -2147343580}