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-noreassoc-outer-4.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer no-scevccp-noreassoc-outer-4.s > no-scevccp-noreassoc-outer-4.ll
6 ; ModuleID = 'no-scevccp-noreassoc-outer-4.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 define i32 @foo() nounwind uwtable noinline {
14 for.cond: ; preds = %for.inc15, %entry
15 %indvar = phi i32 [ %indvar.next, %for.inc15 ], [ 0, %entry ]
16 %exitcond7 = icmp ne i32 %indvar, 196
17 br i1 %exitcond7, label %for.body, label %for.end18
19 for.body: ; preds = %for.cond
22 for.cond1: ; preds = %for.inc, %for.body
23 %tmp = phi i32 [ 0, %for.body ], [ %inc11, %for.inc ]
24 %exitcond = icmp ne i32 %tmp, 40
25 br i1 %exitcond, label %for.body4, label %for.end
27 for.body4: ; preds = %for.cond1
30 for.inc: ; preds = %for.body4
31 %inc11 = add nsw i32 %tmp, 1
34 for.end: ; preds = %for.cond1
37 for.inc15: ; preds = %for.end
38 %indvar.next = add i32 %indvar, 1
41 for.end18: ; preds = %for.cond
45 define i32 @bar(i32 %i, i32 %j) nounwind uwtable noinline {
47 %add = add nsw i32 %i, %j
51 define i32 @main() nounwind uwtable {
53 call void @check_vect()
54 %call = call i32 @foo()
57 for.cond: ; preds = %for.inc15, %entry
58 %indvar = phi i32 [ %indvar.next, %for.inc15 ], [ 0, %entry ]
59 %s.0 = phi i32 [ 0, %entry ], [ %add14, %for.inc15 ]
60 %i.0 = mul i32 %indvar, 41
61 %exitcond3 = icmp ne i32 %indvar, 196
62 br i1 %exitcond3, label %for.body, label %for.end18
64 for.body: ; preds = %for.cond
67 for.cond1: ; preds = %for.inc, %for.body
68 %sum.0 = phi i32 [ 0, %for.body ], [ %add, %for.inc ]
69 %tmp = phi i32 [ 0, %for.body ], [ %inc11, %for.inc ]
70 %i.1 = add i32 %i.0, %tmp
71 %exitcond = icmp ne i32 %tmp, 40
72 br i1 %exitcond, label %for.body4, label %for.end
74 for.body4: ; preds = %for.cond1
75 %call7 = call i32 @bar(i32 %i.1, i32 %tmp)
78 for.inc: ; preds = %for.body4
79 %add = add nsw i32 %sum.0, %call7
80 %inc11 = add nsw i32 %tmp, 1
83 for.end: ; preds = %for.cond1
84 %sum.0.lcssa = phi i32 [ %sum.0, %for.cond1 ]
87 for.inc15: ; preds = %for.end
88 %add14 = add nsw i32 %s.0, %sum.0.lcssa
89 %indvar.next = add i32 %indvar, 1
92 for.end18: ; preds = %for.cond
93 %s.0.lcssa = phi i32 [ %s.0, %for.cond ]
94 %cmp21 = icmp eq i32 %call, %s.0.lcssa
95 br i1 %cmp21, label %if.end, label %if.then
97 if.then: ; preds = %for.end18
98 call void @abort() noreturn nounwind
101 if.end: ; preds = %for.end18
105 define internal void @check_vect() nounwind uwtable noinline {
107 %a = alloca i32, align 4
108 %b = alloca i32, align 4
109 %c = alloca i32, align 4
110 %d = alloca i32, align 4
111 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
112 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
113 %tobool = icmp eq i32 %call1, 0
114 br i1 %tobool, label %if.then, label %lor.lhs.false
116 lor.lhs.false: ; preds = %entry
117 %tmp4 = load i32* %d, align 4
118 %and6 = and i32 %tmp4, 67108864
119 %cmp = icmp eq i32 %and6, 0
120 br i1 %cmp, label %if.then, label %if.end
122 if.then: ; preds = %entry, %lor.lhs.false
123 call void @exit(i32 0) noreturn nounwind
126 if.end: ; preds = %lor.lhs.false
127 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
131 declare void @abort() noreturn
133 declare void (i32)* @signal(i32, void (i32)*) nounwind
135 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
137 call void @exit(i32 0) noreturn nounwind
140 return: ; No predecessors!
144 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
146 %and = and i32 %__level, -2147483648
147 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
148 %cmp = icmp ult i32 %call, %__level
149 br i1 %cmp, label %if.then, label %if.end
151 if.then: ; preds = %entry
154 if.end: ; preds = %entry
155 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
156 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
157 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
158 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
159 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
160 store i32 %asmresult, i32* %__eax, align 4
161 store i32 %asmresult8, i32* %__ebx, align 4
162 store i32 %asmresult9, i32* %__ecx, align 4
163 store i32 %asmresult10, i32* %__edx, align 4
166 return: ; preds = %if.end, %if.then
167 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
171 declare void @exit(i32) noreturn
173 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
175 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
176 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
177 %tobool = icmp eq i32* %__sig, null
178 br i1 %tobool, label %if.end, label %if.then
180 if.then: ; preds = %entry
181 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
182 store i32 %asmresult1, i32* %__sig, align 4
185 if.end: ; preds = %entry, %if.then
189 !0 = metadata !{i32 -2147343497, i32 -2147343489}
190 !1 = metadata !{i32 -2147343620, i32 -2147343612}