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 vect-103.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-103.s > vect-103.ll
6 ; ModuleID = 'vect-103.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 = internal global [9 x i32] [i32 1, i32 2, i32 3, i32 4, i32 5, i32 6, i32 7, i32 8, i32 9], align 16
11 @b = internal global [9 x i32] [i32 17, i32 24, i32 7, i32 0, i32 2, i32 3, i32 4, i32 31, i32 82], align 16
12 @foo = common global i32 0, align 4
13 @c = internal global [9 x i32] [i32 9, i32 17, i32 24, i32 7, i32 0, i32 2, i32 3, i32 4, i32 31], align 16
15 define i32 @main1(i32 %x, i32 %y) nounwind uwtable noinline {
17 %call = call noalias i8* @malloc(i64 72) nounwind
20 for.cond: ; preds = %for.inc, %entry
21 %indvar17 = phi i64 [ %indvar.next18, %for.inc ], [ 0, %entry ]
22 %tmp19 = mul i64 %indvar17, 4
23 %tmp20 = add i64 %tmp19, 36
24 %scevgep21 = getelementptr i8* %call, i64 %tmp20
25 %arrayidx14 = bitcast i8* %scevgep21 to i32*
26 %arrayidx9 = getelementptr [9 x i32]* @b, i64 0, i64 %indvar17
27 %scevgep24 = getelementptr i8* %call, i64 %tmp19
28 %arrayidx6 = bitcast i8* %scevgep24 to i32*
29 %arrayidx = getelementptr [9 x i32]* @a, i64 0, i64 %indvar17
30 %i.0 = trunc i64 %indvar17 to i32
31 %cmp = icmp slt i32 %i.0, 9
32 br i1 %cmp, label %for.body, label %for.end
34 for.body: ; preds = %for.cond
35 %tmp2 = load i32* %arrayidx, align 4
36 store i32 %tmp2, i32* %arrayidx6, align 4
37 %tmp10 = load i32* %arrayidx9, align 4
38 store i32 %tmp10, i32* %arrayidx14, align 4
39 %tmp15 = volatile load i32* @foo, align 4
40 %cmp16 = icmp eq i32 %tmp15, 135
41 br i1 %cmp16, label %if.then, label %if.end
43 if.then: ; preds = %for.body
44 call void @abort() noreturn nounwind
47 if.end: ; preds = %for.body
50 for.inc: ; preds = %if.end
51 %indvar.next18 = add i64 %indvar17, 1
54 for.end: ; preds = %for.cond
55 %tmp7 = sext i32 %x to i64
56 %tmp8 = mul i64 %tmp7, 4
57 %tmp12 = add i64 %tmp8, 32
60 for.cond18: ; preds = %for.inc36, %for.end
61 %indvar4 = phi i64 [ %indvar.next5, %for.inc36 ], [ 0, %for.end ]
62 %tmp6 = mul i64 %indvar4, 4
63 %tmp9 = add i64 %tmp8, %tmp6
64 %scevgep10 = getelementptr i8* %call, i64 %tmp9
65 %add.ptr35 = bitcast i8* %scevgep10 to i32*
66 %tmp13 = add i64 %tmp12, %tmp6
67 %scevgep14 = getelementptr i8* %call, i64 %tmp13
68 %add.ptr27 = bitcast i8* %scevgep14 to i32*
69 %exitcond = icmp ne i64 %indvar4, 9
70 br i1 %exitcond, label %for.body21, label %for.end39
72 for.body21: ; preds = %for.cond18
73 %tmp28 = load i32* %add.ptr27, align 4
74 store i32 %tmp28, i32* %add.ptr35, align 4
77 for.inc36: ; preds = %for.body21
78 %indvar.next5 = add i64 %indvar4, 1
81 for.end39: ; preds = %for.cond18
84 for.cond40: ; preds = %for.inc57, %for.end39
85 %indvar = phi i64 [ %indvar.next, %for.inc57 ], [ 0, %for.end39 ]
86 %arrayidx52 = getelementptr [9 x i32]* @c, i64 0, i64 %indvar
87 %tmp = mul i64 %indvar, 4
88 %scevgep = getelementptr i8* %call, i64 %tmp
89 %arrayidx48 = bitcast i8* %scevgep to i32*
90 %i.2 = trunc i64 %indvar to i32
91 %cmp42 = icmp slt i32 %i.2, 9
92 br i1 %cmp42, label %for.body43, label %for.end60
94 for.body43: ; preds = %for.cond40
95 %tmp49 = load i32* %arrayidx48, align 4
96 %tmp53 = load i32* %arrayidx52, align 4
97 %cmp54 = icmp eq i32 %tmp49, %tmp53
98 br i1 %cmp54, label %if.end56, label %if.then55
100 if.then55: ; preds = %for.body43
101 call void @abort() noreturn nounwind
104 if.end56: ; preds = %for.body43
107 for.inc57: ; preds = %if.end56
108 %indvar.next = add i64 %indvar, 1
111 for.end60: ; preds = %for.cond40
115 declare noalias i8* @malloc(i64) nounwind
117 declare void @abort() noreturn nounwind
119 define i32 @main() nounwind uwtable {
121 call void @check_vect()
122 volatile store i32 0, i32* @foo, align 4
123 %call = call i32 @main1(i32 0, i32 9)
127 define internal void @check_vect() nounwind uwtable noinline {
129 %a = alloca i32, align 4
130 %b = alloca i32, align 4
131 %c = alloca i32, align 4
132 %d = alloca i32, align 4
133 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
134 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
135 %tobool = icmp eq i32 %call1, 0
136 br i1 %tobool, label %if.then, label %lor.lhs.false
138 lor.lhs.false: ; preds = %entry
139 %tmp4 = load i32* %d, align 4
140 %and6 = and i32 %tmp4, 67108864
141 %cmp = icmp eq i32 %and6, 0
142 br i1 %cmp, label %if.then, label %if.end
144 if.then: ; preds = %entry, %lor.lhs.false
145 call void @exit(i32 0) noreturn nounwind
148 if.end: ; preds = %lor.lhs.false
149 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
153 declare void (i32)* @signal(i32, void (i32)*) nounwind
155 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
157 call void @exit(i32 0) noreturn nounwind
160 return: ; No predecessors!
164 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
166 %and = and i32 %__level, -2147483648
167 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
168 %cmp = icmp ult i32 %call, %__level
169 br i1 %cmp, label %if.then, label %if.end
171 if.then: ; preds = %entry
174 if.end: ; preds = %entry
175 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
176 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
177 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
178 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
179 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
180 store i32 %asmresult, i32* %__eax, align 4
181 store i32 %asmresult8, i32* %__ebx, align 4
182 store i32 %asmresult9, i32* %__ecx, align 4
183 store i32 %asmresult10, i32* %__edx, align 4
186 return: ; preds = %if.end, %if.then
187 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
191 declare void @exit(i32) noreturn nounwind
193 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
195 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
196 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
197 %tobool = icmp eq i32* %__sig, null
198 br i1 %tobool, label %if.end, label %if.then
200 if.then: ; preds = %entry
201 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
202 store i32 %asmresult1, i32* %__sig, align 4
205 if.end: ; preds = %entry, %if.then
209 !0 = metadata !{i32 -2147225987, i32 -2147225979}
210 !1 = metadata !{i32 -2147226110, i32 -2147226102}