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-98.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-98.s > vect-98.ll
6 ; ModuleID = 'vect-98.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 @main1.ib = internal unnamed_addr constant [4 x i32] [i32 0, i32 3, i32 6, i32 9], align 16
11 @main.ia = internal unnamed_addr constant [4 x [4 x i32]] [[4 x i32] [i32 1, i32 2, i32 3, i32 4], [4 x i32] [i32 2, i32 3, i32 5, i32 7], [4 x i32] [i32 2, i32 4, i32 6, i32 8], [4 x i32] [i32 22, i32 43, i32 55, i32 77]], align 16
13 define i32 @main1([4 x i32]* %ia) nounwind uwtable noinline {
15 %ib = alloca [4 x i32], align 16
16 %ic = alloca [4 x [4 x i32]], align 16
17 %tmp = bitcast [4 x i32]* %ib to i8*
18 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp, i8* bitcast ([4 x i32]* @main1.ib to i8*), i64 16, i32 16, i1 false)
21 for.cond: ; preds = %for.inc, %entry
22 %indvar2 = phi i64 [ %indvar.next3, %for.inc ], [ 0, %entry ]
23 %arrayidx41 = getelementptr [4 x [4 x i32]]* %ic, i64 0, i64 0, i64 %indvar2
24 %arrayidx32 = getelementptr [4 x i32]* %ia, i64 %indvar2, i64 3
25 %arrayidx22 = getelementptr [4 x i32]* %ia, i64 %indvar2, i64 2
26 %arrayidx13 = getelementptr [4 x i32]* %ia, i64 %indvar2, i64 1
27 %arrayidx5 = getelementptr [4 x i32]* %ia, i64 %indvar2, i64 0
28 %exitcond = icmp ne i64 %indvar2, 4
29 br i1 %exitcond, label %for.body, label %for.end
31 for.body: ; preds = %for.cond
32 %tmp6 = load i32* %arrayidx5, align 4
33 %arrayidx7 = getelementptr inbounds [4 x i32]* %ib, i64 0, i64 0
34 %tmp8 = load i32* %arrayidx7, align 16
35 %mul = mul nsw i32 %tmp6, %tmp8
36 %tmp14 = load i32* %arrayidx13, align 4
37 %arrayidx15 = getelementptr inbounds [4 x i32]* %ib, i64 0, i64 1
38 %tmp16 = load i32* %arrayidx15, align 4
39 %mul17 = mul nsw i32 %tmp14, %tmp16
40 %add = add nsw i32 %mul, %mul17
41 %tmp23 = load i32* %arrayidx22, align 4
42 %arrayidx24 = getelementptr inbounds [4 x i32]* %ib, i64 0, i64 2
43 %tmp25 = load i32* %arrayidx24, align 8
44 %mul26 = mul nsw i32 %tmp23, %tmp25
45 %add27 = add nsw i32 %add, %mul26
46 %tmp33 = load i32* %arrayidx32, align 4
47 %arrayidx34 = getelementptr inbounds [4 x i32]* %ib, i64 0, i64 3
48 %tmp35 = load i32* %arrayidx34, align 4
49 %mul36 = mul nsw i32 %tmp33, %tmp35
50 %add37 = add nsw i32 %add27, %mul36
51 store i32 %add37, i32* %arrayidx41, align 4
54 for.inc: ; preds = %for.body
55 %indvar.next3 = add i64 %indvar2, 1
58 for.end: ; preds = %for.cond
61 for.cond43: ; preds = %for.inc92, %for.end
62 %indvar = phi i64 [ %indvar.next, %for.inc92 ], [ 0, %for.end ]
63 %arrayidx85 = getelementptr [4 x i32]* %ia, i64 %indvar, i64 3
64 %arrayidx75 = getelementptr [4 x i32]* %ia, i64 %indvar, i64 2
65 %arrayidx65 = getelementptr [4 x i32]* %ia, i64 %indvar, i64 1
66 %arrayidx56 = getelementptr [4 x i32]* %ia, i64 %indvar, i64 0
67 %arrayidx50 = getelementptr [4 x [4 x i32]]* %ic, i64 0, i64 0, i64 %indvar
68 %i.1 = trunc i64 %indvar to i32
69 %cmp45 = icmp slt i32 %i.1, 4
70 br i1 %cmp45, label %for.body46, label %for.end95
72 for.body46: ; preds = %for.cond43
73 %tmp51 = load i32* %arrayidx50, align 4
74 %tmp57 = load i32* %arrayidx56, align 4
75 %arrayidx58 = getelementptr inbounds [4 x i32]* %ib, i64 0, i64 0
76 %tmp59 = load i32* %arrayidx58, align 16
77 %mul60 = mul nsw i32 %tmp57, %tmp59
78 %tmp66 = load i32* %arrayidx65, align 4
79 %arrayidx67 = getelementptr inbounds [4 x i32]* %ib, i64 0, i64 1
80 %tmp68 = load i32* %arrayidx67, align 4
81 %mul69 = mul nsw i32 %tmp66, %tmp68
82 %add70 = add nsw i32 %mul60, %mul69
83 %tmp76 = load i32* %arrayidx75, align 4
84 %arrayidx77 = getelementptr inbounds [4 x i32]* %ib, i64 0, i64 2
85 %tmp78 = load i32* %arrayidx77, align 8
86 %mul79 = mul nsw i32 %tmp76, %tmp78
87 %add80 = add nsw i32 %add70, %mul79
88 %tmp86 = load i32* %arrayidx85, align 4
89 %arrayidx87 = getelementptr inbounds [4 x i32]* %ib, i64 0, i64 3
90 %tmp88 = load i32* %arrayidx87, align 4
91 %mul89 = mul nsw i32 %tmp86, %tmp88
92 %add90 = add nsw i32 %add80, %mul89
93 %cmp91 = icmp eq i32 %tmp51, %add90
94 br i1 %cmp91, label %if.end, label %if.then
96 if.then: ; preds = %for.body46
97 call void @abort() noreturn nounwind
100 if.end: ; preds = %for.body46
103 for.inc92: ; preds = %if.end
104 %indvar.next = add i64 %indvar, 1
107 for.end95: ; preds = %for.cond43
111 declare void @llvm.memcpy.p0i8.p0i8.i64(i8* nocapture, i8* nocapture, i64, i32, i1) nounwind
113 declare void @abort() noreturn
115 define i32 @main() nounwind uwtable {
117 %ia = alloca [4 x [4 x i32]], align 16
118 %tmp = bitcast [4 x [4 x i32]]* %ia to i8*
119 call void @llvm.memcpy.p0i8.p0i8.i64(i8* %tmp, i8* bitcast ([4 x [4 x i32]]* @main.ia to i8*), i64 64, i32 16, i1 false)
120 call void @check_vect()
121 %arraydecay = getelementptr inbounds [4 x [4 x i32]]* %ia, i64 0, i64 0
122 %call = call i32 @main1([4 x i32]* %arraydecay)
126 define internal void @check_vect() nounwind uwtable noinline {
128 %a = alloca i32, align 4
129 %b = alloca i32, align 4
130 %c = alloca i32, align 4
131 %d = alloca i32, align 4
132 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
133 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
134 %tobool = icmp eq i32 %call1, 0
135 br i1 %tobool, label %if.then, label %lor.lhs.false
137 lor.lhs.false: ; preds = %entry
138 %tmp4 = load i32* %d, align 4
139 %and6 = and i32 %tmp4, 67108864
140 %cmp = icmp eq i32 %and6, 0
141 br i1 %cmp, label %if.then, label %if.end
143 if.then: ; preds = %entry, %lor.lhs.false
144 call void @exit(i32 0) noreturn nounwind
147 if.end: ; preds = %lor.lhs.false
148 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
152 declare void (i32)* @signal(i32, void (i32)*) nounwind
154 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
156 call void @exit(i32 0) noreturn nounwind
159 return: ; No predecessors!
163 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
165 %and = and i32 %__level, -2147483648
166 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
167 %cmp = icmp ult i32 %call, %__level
168 br i1 %cmp, label %if.then, label %if.end
170 if.then: ; preds = %entry
173 if.end: ; preds = %entry
174 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
175 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
176 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
177 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
178 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
179 store i32 %asmresult, i32* %__eax, align 4
180 store i32 %asmresult8, i32* %__ebx, align 4
181 store i32 %asmresult9, i32* %__ecx, align 4
182 store i32 %asmresult10, i32* %__edx, align 4
185 return: ; preds = %if.end, %if.then
186 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
190 declare void @exit(i32) noreturn
192 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
194 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
195 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
196 %tobool = icmp eq i32* %__sig, null
197 br i1 %tobool, label %if.end, label %if.then
199 if.then: ; preds = %entry
200 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
201 store i32 %asmresult1, i32* %__sig, align 4
204 if.end: ; preds = %entry, %if.then
208 !0 = metadata !{i32 -2147343422, i32 -2147343414}
209 !1 = metadata !{i32 -2147343545, i32 -2147343537}