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-6.c
4 ; opt -correlated-propagation -mem2reg -instcombine -loop-simplify -indvars -instnamer vect-6.s > vect-6.ll
6 ; ModuleID = 'vect-6.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 @results1 = global [16 x float] [float 1.920000e+02, float 2.400000e+02, float 2.880000e+02, float 3.360000e+02, float 3.840000e+02, float 4.320000e+02, float 4.800000e+02, float 5.280000e+02, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00], align 16
11 @results2 = global [16 x float] [float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 0.000000e+00, float 5.400000e+01, float 1.200000e+02, float 1.980000e+02, float 2.880000e+02, float 3.900000e+02, float 5.040000e+02, float 6.300000e+02], align 16
12 @a = global [16 x float] zeroinitializer, align 16
13 @e = global [16 x float] zeroinitializer, align 16
14 @b = global [16 x float] [float 0.000000e+00, float 3.000000e+00, float 6.000000e+00, float 9.000000e+00, float 1.200000e+01, float 1.500000e+01, float 1.800000e+01, float 2.100000e+01, float 2.400000e+01, float 2.700000e+01, float 3.000000e+01, float 3.300000e+01, float 3.600000e+01, float 3.900000e+01, float 4.200000e+01, float 4.500000e+01], align 16
15 @c = global [16 x float] [float 0.000000e+00, float 1.000000e+00, float 2.000000e+00, float 3.000000e+00, float 4.000000e+00, float 5.000000e+00, float 6.000000e+00, float 7.000000e+00, float 8.000000e+00, float 9.000000e+00, float 1.000000e+01, float 1.100000e+01, float 1.200000e+01, float 1.300000e+01, float 1.400000e+01, float 1.500000e+01], align 16
17 define i32 @main1() nounwind uwtable noinline {
21 for.cond: ; preds = %for.inc, %entry
22 %indvar13 = phi i64 [ %indvar.next14, %for.inc ], [ 0, %entry ]
23 %tmp16 = add i64 %indvar13, 8
24 %arrayidx44 = getelementptr [16 x float]* @e, i64 0, i64 %tmp16
25 %arrayidx14 = getelementptr [16 x float]* @c, i64 0, i64 %indvar13
26 %arrayidx = getelementptr [16 x float]* @b, i64 0, i64 %tmp16
27 %arrayidx6 = getelementptr [16 x float]* @c, i64 0, i64 %tmp16
28 %arrayidx10 = getelementptr [16 x float]* @b, i64 0, i64 %indvar13
29 %arrayidx19 = getelementptr [16 x float]* @a, i64 0, i64 %indvar13
30 %exitcond15 = icmp ne i64 %indvar13, 8
31 br i1 %exitcond15, label %for.body, label %for.end
33 for.body: ; preds = %for.cond
34 %tmp2 = load float* %arrayidx, align 4
35 %tmp7 = load float* %arrayidx6, align 4
36 %mul = fmul float %tmp2, %tmp7
37 %tmp11 = load float* %arrayidx10, align 4
38 %tmp15 = load float* %arrayidx14, align 4
39 %mul16 = fmul float %tmp11, %tmp15
40 %sub = fsub float %mul, %mul16
41 store float %sub, float* %arrayidx19, align 4
42 %tmp23 = load float* %arrayidx10, align 4
43 %tmp28 = load float* %arrayidx6, align 4
44 %mul29 = fmul float %tmp23, %tmp28
45 %tmp34 = load float* %arrayidx, align 4
46 %tmp38 = load float* %arrayidx14, align 4
47 %mul39 = fmul float %tmp34, %tmp38
48 %add40 = fadd float %mul29, %mul39
49 store float %add40, float* %arrayidx44, align 4
52 for.inc: ; preds = %for.body
53 %indvar.next14 = add i64 %indvar13, 1
56 for.end: ; preds = %for.cond
59 for.cond46: ; preds = %for.inc68, %for.end
60 %indvar10 = phi i64 [ %indvar.next11, %for.inc68 ], [ 0, %for.end ]
61 %arrayidx65 = getelementptr [16 x float]* @results2, i64 0, i64 %indvar10
62 %arrayidx61 = getelementptr [16 x float]* @e, i64 0, i64 %indvar10
63 %arrayidx56 = getelementptr [16 x float]* @results1, i64 0, i64 %indvar10
64 %arrayidx52 = getelementptr [16 x float]* @a, i64 0, i64 %indvar10
65 %i.1 = trunc i64 %indvar10 to i32
66 %cmp48 = icmp slt i32 %i.1, 16
67 br i1 %cmp48, label %for.body49, label %for.end71
69 for.body49: ; preds = %for.cond46
70 %tmp53 = load float* %arrayidx52, align 4
71 %tmp57 = load float* %arrayidx56, align 4
72 %cmp58 = fcmp une float %tmp53, %tmp57
73 br i1 %cmp58, label %if.then, label %lor.lhs.false
75 lor.lhs.false: ; preds = %for.body49
76 %tmp62 = load float* %arrayidx61, align 4
77 %tmp66 = load float* %arrayidx65, align 4
78 %cmp67 = fcmp une float %tmp62, %tmp66
79 br i1 %cmp67, label %if.then, label %if.end
81 if.then: ; preds = %lor.lhs.false, %for.body49
82 call void @abort() noreturn nounwind
85 if.end: ; preds = %lor.lhs.false
88 for.inc68: ; preds = %if.end
89 %indvar.next11 = add i64 %indvar10, 1
92 for.end71: ; preds = %for.cond46
95 for.cond72: ; preds = %for.inc85, %for.end71
96 %indvar4 = phi i64 [ %indvar.next5, %for.inc85 ], [ 0, %for.end71 ]
97 %arrayidx79 = getelementptr [16 x float]* @b, i64 0, i64 %indvar4
98 %tmp9 = add i64 %indvar4, 4
99 %arrayidx84 = getelementptr [16 x float]* @a, i64 0, i64 %tmp9
100 %exitcond = icmp ne i64 %indvar4, 12
101 br i1 %exitcond, label %for.body75, label %for.end88
103 for.body75: ; preds = %for.cond72
104 %tmp80 = load float* %arrayidx79, align 4
105 store float %tmp80, float* %arrayidx84, align 4
108 for.inc85: ; preds = %for.body75
109 %indvar.next5 = add i64 %indvar4, 1
112 for.end88: ; preds = %for.cond72
115 for.cond89: ; preds = %for.inc106, %for.end88
116 %indvar = phi i64 [ %indvar.next, %for.inc106 ], [ 0, %for.end88 ]
117 %arrayidx101 = getelementptr [16 x float]* @b, i64 0, i64 %indvar
118 %tmp = add i64 %indvar, 1
119 %i.3 = trunc i64 %tmp to i32
120 %tmp3 = add i64 %indvar, 4
121 %arrayidx96 = getelementptr [16 x float]* @a, i64 0, i64 %tmp3
122 %cmp91 = icmp slt i32 %i.3, 13
123 br i1 %cmp91, label %for.body92, label %for.end109
125 for.body92: ; preds = %for.cond89
126 %tmp97 = load float* %arrayidx96, align 4
127 %tmp102 = load float* %arrayidx101, align 4
128 %cmp103 = fcmp une float %tmp97, %tmp102
129 br i1 %cmp103, label %if.then104, label %if.end105
131 if.then104: ; preds = %for.body92
132 call void @abort() noreturn nounwind
135 if.end105: ; preds = %for.body92
138 for.inc106: ; preds = %if.end105
139 %indvar.next = add i64 %indvar, 1
142 for.end109: ; preds = %for.cond89
146 declare void @abort() noreturn
148 define i32 @main() nounwind uwtable {
150 call void @check_vect()
151 %call = call i32 @main1()
155 define internal void @check_vect() nounwind uwtable noinline {
157 %a = alloca i32, align 4
158 %b = alloca i32, align 4
159 %c = alloca i32, align 4
160 %d = alloca i32, align 4
161 %call = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* @sig_ill_handler) nounwind
162 %call1 = call i32 @__get_cpuid(i32 1, i32* %a, i32* %b, i32* %c, i32* %d)
163 %tobool = icmp eq i32 %call1, 0
164 br i1 %tobool, label %if.then, label %lor.lhs.false
166 lor.lhs.false: ; preds = %entry
167 %tmp4 = load i32* %d, align 4
168 %and6 = and i32 %tmp4, 67108864
169 %cmp = icmp eq i32 %and6, 0
170 br i1 %cmp, label %if.then, label %if.end
172 if.then: ; preds = %entry, %lor.lhs.false
173 call void @exit(i32 0) noreturn nounwind
176 if.end: ; preds = %lor.lhs.false
177 %call7 = call void (i32)* (i32, void (i32)*)* @signal(i32 4, void (i32)* null) nounwind
181 declare void (i32)* @signal(i32, void (i32)*) nounwind
183 define internal void @sig_ill_handler(i32 %sig) nounwind uwtable {
185 call void @exit(i32 0) noreturn nounwind
188 return: ; No predecessors!
192 define internal i32 @__get_cpuid(i32 %__level, i32* %__eax, i32* %__ebx, i32* %__ecx, i32* %__edx) nounwind uwtable inlinehint {
194 %and = and i32 %__level, -2147483648
195 %call = call i32 @__get_cpuid_max(i32 %and, i32* null)
196 %cmp = icmp ult i32 %call, %__level
197 br i1 %cmp, label %if.then, label %if.end
199 if.then: ; preds = %entry
202 if.end: ; preds = %entry
203 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__level) nounwind, !srcloc !0
204 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
205 %asmresult8 = extractvalue { i32, i32, i32, i32 } %tmp, 1
206 %asmresult9 = extractvalue { i32, i32, i32, i32 } %tmp, 2
207 %asmresult10 = extractvalue { i32, i32, i32, i32 } %tmp, 3
208 store i32 %asmresult, i32* %__eax, align 4
209 store i32 %asmresult8, i32* %__ebx, align 4
210 store i32 %asmresult9, i32* %__ecx, align 4
211 store i32 %asmresult10, i32* %__edx, align 4
214 return: ; preds = %if.end, %if.then
215 %retval.0 = phi i32 [ 0, %if.then ], [ 1, %if.end ]
219 declare void @exit(i32) noreturn
221 define internal i32 @__get_cpuid_max(i32 %__ext, i32* %__sig) nounwind uwtable inlinehint {
223 %tmp = call { i32, i32, i32, i32 } asm "cpuid\0A\09", "={ax},={bx},={cx},={dx},0,~{dirflag},~{fpsr},~{flags}"(i32 %__ext) nounwind, !srcloc !1
224 %asmresult = extractvalue { i32, i32, i32, i32 } %tmp, 0
225 %tobool = icmp eq i32* %__sig, null
226 br i1 %tobool, label %if.end, label %if.then
228 if.then: ; preds = %entry
229 %asmresult1 = extractvalue { i32, i32, i32, i32 } %tmp, 1
230 store i32 %asmresult1, i32* %__sig, align 4
233 if.end: ; preds = %entry, %if.then
237 !0 = metadata !{i32 -2147343087, i32 -2147343079}
238 !1 = metadata !{i32 -2147343210, i32 -2147343202}