1; RUN: opt < %s -basicaa -slp-vectorizer -dce -S -mtriple=i386-apple-macosx10.8.0 -mcpu=corei7-avx | FileCheck %s
2
3target datalayout = "e-p:32:32:32-i1:8:8-i8:8:8-i16:16:16-i32:32:32-i64:32:64-f32:32:32-f64:32:64-v64:64:64-v128:128:128-a0:0:64-f80:128:128-n8:16:32-S128"
4target triple = "i386-apple-macosx10.9.0"
5
6; We disable the vectorization of <3 x float> for now
7
8; float foo(float *A) {
9;
10;   float R = A[0];
11;   float G = A[1];
12;   float B = A[2];
13;   for (int i=0; i < 121; i+=3) {
14;     R+=A[i+0]*7;
15;     G+=A[i+1]*8;
16;     B+=A[i+2]*9;
17;   }
18;
19;   return R+G+B;
20; }
21
22;CHECK-LABEL: @foo(
23;CHECK: br
24;CHECK-NOT: phi <3 x float>
25;CHECK-NOT: fmul <3 x float>
26;CHECK-NOT: fadd <3 x float>
27; At the moment we don't sink extractelements.
28;CHECK: br
29;CHECK-NOT: extractelement
30;CHECK-NOT: extractelement
31;CHECK-NOT: extractelement
32;CHECK: ret
33
34define float @foo(float* nocapture readonly %A) {
35entry:
36  %0 = load float* %A, align 4
37  %arrayidx1 = getelementptr inbounds float* %A, i64 1
38  %1 = load float* %arrayidx1, align 4
39  %arrayidx2 = getelementptr inbounds float* %A, i64 2
40  %2 = load float* %arrayidx2, align 4
41  br label %for.body
42
43for.body:                                         ; preds = %for.body.for.body_crit_edge, %entry
44  %3 = phi float [ %0, %entry ], [ %.pre, %for.body.for.body_crit_edge ]
45  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body.for.body_crit_edge ]
46  %B.032 = phi float [ %2, %entry ], [ %add14, %for.body.for.body_crit_edge ]
47  %G.031 = phi float [ %1, %entry ], [ %add9, %for.body.for.body_crit_edge ]
48  %R.030 = phi float [ %0, %entry ], [ %add4, %for.body.for.body_crit_edge ]
49  %mul = fmul float %3, 7.000000e+00
50  %add4 = fadd float %R.030, %mul
51  %4 = add nsw i64 %indvars.iv, 1
52  %arrayidx7 = getelementptr inbounds float* %A, i64 %4
53  %5 = load float* %arrayidx7, align 4
54  %mul8 = fmul float %5, 8.000000e+00
55  %add9 = fadd float %G.031, %mul8
56  %6 = add nsw i64 %indvars.iv, 2
57  %arrayidx12 = getelementptr inbounds float* %A, i64 %6
58  %7 = load float* %arrayidx12, align 4
59  %mul13 = fmul float %7, 9.000000e+00
60  %add14 = fadd float %B.032, %mul13
61  %indvars.iv.next = add i64 %indvars.iv, 3
62  %8 = trunc i64 %indvars.iv.next to i32
63  %cmp = icmp slt i32 %8, 121
64  br i1 %cmp, label %for.body.for.body_crit_edge, label %for.end
65
66for.body.for.body_crit_edge:                      ; preds = %for.body
67  %arrayidx3.phi.trans.insert = getelementptr inbounds float* %A, i64 %indvars.iv.next
68  %.pre = load float* %arrayidx3.phi.trans.insert, align 4
69  br label %for.body
70
71for.end:                                          ; preds = %for.body
72  %add16 = fadd float %add4, %add9
73  %add17 = fadd float %add16, %add14
74  ret float %add17
75}
76
77