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-10b.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer no-scevccp-outer-10b.s > no-scevccp-outer-10b.ll
6 ; ModuleID = 'no-scevccp-outer-10b.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 %cmp = icmp slt i32 %n, 1
16 br i1 %cmp, label %if.then, label %if.end
18 if.then: ; preds = %entry
21 if.end: ; preds = %entry
22 %tmp = zext i32 %n to i33
23 %tmp3 = add i32 %n, -1
24 %tmp5 = zext i32 %tmp3 to i33
25 %tmp6 = mul i33 %tmp, %tmp5
26 %tmp7 = lshr i33 %tmp6, 1
27 %tmp8 = trunc i33 %tmp7 to i32
30 for.cond: ; preds = %for.inc34, %if.end
31 %indvar = phi i64 [ %indvar.next, %for.inc34 ], [ 0, %if.end ]
32 %tmp10 = mul i64 %indvar, 2
33 %tmp11 = add i64 %tmp10, 1
34 %arrayidx33 = getelementptr [40 x i32]* @a, i64 0, i64 %tmp11
35 %arrayidx25 = getelementptr [40 x i32]* @a, i64 0, i64 %tmp10
36 %arrayidx8 = getelementptr [40 x i32]* @b, i64 0, i64 %tmp11
37 %arrayidx = getelementptr [40 x i32]* @b, i64 0, i64 %tmp10
38 %exitcond9 = icmp ne i64 %indvar, 20
39 br i1 %exitcond9, label %for.body, label %for.end37.loopexit
41 for.body: ; preds = %for.cond
42 %tmp4 = load i32* %arrayidx, align 8
43 %tmp9 = load i32* %arrayidx8, align 4
46 for.cond10: ; preds = %for.inc, %for.body
47 %tmp13 = phi i32 [ 0, %for.body ], [ %inc, %for.inc ]
48 %exitcond = icmp ne i32 %tmp13, %n
49 br i1 %exitcond, label %for.body14, label %for.end
51 for.body14: ; preds = %for.cond10
54 for.inc: ; preds = %for.body14
55 %inc = add nsw i32 %tmp13, 1
58 for.end: ; preds = %for.cond10
59 %add21 = add nsw i32 %tmp8, %tmp4
60 store i32 %add21, i32* %arrayidx25, align 8
61 %add28 = add nsw i32 %tmp8, %tmp9
62 store i32 %add28, i32* %arrayidx33, align 4
65 for.inc34: ; preds = %for.end
66 %indvar.next = add i64 %indvar, 1
69 for.end37.loopexit: ; preds = %for.cond
72 for.end37: ; preds = %for.end37.loopexit, %if.then
76 define i32 @main() nounwind uwtable {
78 call void @check_vect()
81 for.cond: ; preds = %for.inc, %entry
82 %indvar5 = phi i64 [ %indvar.next6, %for.inc ], [ 0, %entry ]
83 %arrayidx = getelementptr [40 x i32]* @b, i64 0, i64 %indvar5
84 %i.0 = trunc i64 %indvar5 to i32
85 %exitcond7 = icmp ne i64 %indvar5, 40
86 br i1 %exitcond7, label %for.body, label %for.end
88 for.body: ; preds = %for.cond
89 store i32 %i.0, i32* %arrayidx, align 4
92 for.inc: ; preds = %for.body
93 %indvar.next6 = add i64 %indvar5, 1
96 for.end: ; preds = %for.cond
97 %call = call i32 @foo(i32 39)
100 for.cond4: ; preds = %for.inc45, %for.end
101 %indvar = phi i64 [ %indvar.next, %for.inc45 ], [ 0, %for.end ]
102 %tmp = mul i64 %indvar, 2
103 %tmp3 = add i64 %tmp, 1
104 %arrayidx41 = getelementptr [40 x i32]* @b, i64 0, i64 %tmp3
105 %arrayidx34 = getelementptr [40 x i32]* @a, i64 0, i64 %tmp3
106 %arrayidx26 = getelementptr [40 x i32]* @b, i64 0, i64 %tmp
107 %arrayidx20 = getelementptr [40 x i32]* @a, i64 0, i64 %tmp
108 %i.1 = trunc i64 %indvar to i32
109 %cmp6 = icmp slt i32 %i.1, 20
110 br i1 %cmp6, label %for.body7, label %for.end48
112 for.body7: ; preds = %for.cond4
115 for.cond8: ; preds = %for.inc14, %for.body7
116 %tmp9 = phi i32 [ 0, %for.body7 ], [ %inc16, %for.inc14 ]
117 %exitcond = icmp ne i32 %tmp9, 39
118 br i1 %exitcond, label %for.body11, label %for.end17
120 for.body11: ; preds = %for.cond8
123 for.inc14: ; preds = %for.body11
124 %inc16 = add nsw i32 %tmp9, 1
127 for.end17: ; preds = %for.cond8
128 %tmp21 = load i32* %arrayidx20, align 8
129 %tmp27 = load i32* %arrayidx26, align 8
130 %add28 = add nsw i32 741, %tmp27
131 %cmp29 = icmp eq i32 %tmp21, %add28
132 br i1 %cmp29, label %lor.lhs.false, label %if.then
134 lor.lhs.false: ; preds = %for.end17
135 %tmp35 = load i32* %arrayidx34, align 4
136 %tmp42 = load i32* %arrayidx41, align 4
137 %add43 = add nsw i32 741, %tmp42
138 %cmp44 = icmp eq i32 %tmp35, %add43
139 br i1 %cmp44, label %if.end, label %if.then
141 if.then: ; preds = %lor.lhs.false, %for.end17
142 call void @abort() noreturn nounwind
145 if.end: ; preds = %lor.lhs.false
148 for.inc45: ; preds = %if.end
149 %indvar.next = add i64 %indvar, 1
152 for.end48: ; preds = %for.cond4
156 define internal void @check_vect() nounwind uwtable noinline {
158 %a = alloca i32, align 4
159 %b = alloca i32, align 4
160 %c = alloca i32, align 4
161 %d = alloca i32, align 4
162 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
163 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
164 %tobool = icmp eq i32 %call1, 0
165 br i1 %tobool, label %if.then, label %lor.lhs.false
167 lor.lhs.false: ; preds = %entry
168 %tmp4 = load i32* %d, align 4
169 %and6 = and i32 %tmp4, 67108864
170 %cmp = icmp eq i32 %and6, 0
171 br i1 %cmp, label %if.then, label %if.end
173 if.then: ; preds = %entry, %lor.lhs.false
174 call void @exit(i32 0) noreturn nounwind
177 if.end: ; preds = %lor.lhs.false
178 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
182 declare void @abort() noreturn
184 declare void (i32)* @signal(i32, void (i32)*) nounwind
186 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
188 call void @exit(i32 0) noreturn nounwind
191 return: ; No predecessors!
195 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
197 %and = and i32 %__level, -2147483648
198 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
199 %cmp = icmp ult i32 %call, %__level
200 br i1 %cmp, label %if.then, label %if.end
202 if.then: ; preds = %entry
205 if.end: ; preds = %entry
206 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
207 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
208 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
209 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
210 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
211 store i32 %asmresult, i32* %__eax, align 4
212 store i32 %asmresult8, i32* %__ebx, align 4
213 store i32 %asmresult9, i32* %__ecx, align 4
214 store i32 %asmresult10, i32* %__edx, align 4
217 return: ; preds = %if.end, %if.then
218 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
222 declare void @exit(i32) noreturn
224 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
226 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
227 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
228 %tobool = icmp eq i32* %__sig, null
229 br i1 %tobool, label %if.end, label %if.then
231 if.then: ; preds = %entry
232 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
233 store i32 %asmresult1, i32* %__sig, align 4
236 if.end: ; preds = %entry, %if.then
240 !0 = metadata !{i32 -2147343429, i32 -2147343421}
241 !1 = metadata !{i32 -2147343552, i32 -2147343544}