1 ; RUN: opt < %s -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -dce -instcombine -pass-remarks=loop-vectorize -pass-remarks-missed=loop-vectorize -S 2>&1 | FileCheck %s
3 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-S128"
4 target triple = "x86_64-apple-macosx10.8.0"
6 ; First loop produced diagnostic pass remark.
7 ;CHECK: remark: {{.*}}:0:0: vectorized loop (vectorization width: 4, interleaved count: 1)
8 ; Second loop produces diagnostic analysis remark.
9 ;CHECK: remark: {{.*}}:0:0: loop not vectorized: cannot prove pointers refer to independent arrays in memory. The loop requires 11 runtime independence checks to vectorize the loop, but that would exceed the limit of 8 checks
11 ; We are vectorizing with 6 runtime checks.
12 ;CHECK-LABEL: func1x6(
15 define i32 @func1x6(i32* nocapture %out, i32* nocapture %A, i32* nocapture %B, i32* nocapture %C, i32* nocapture %D, i32* nocapture %E, i32* nocapture %F) {
19 for.body: ; preds = %for.body, %entry
20 %i.016 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
21 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %i.016
22 %0 = load i32, i32* %arrayidx, align 4
23 %arrayidx1 = getelementptr inbounds i32, i32* %B, i64 %i.016
24 %1 = load i32, i32* %arrayidx1, align 4
25 %add = add nsw i32 %1, %0
26 %arrayidx2 = getelementptr inbounds i32, i32* %C, i64 %i.016
27 %2 = load i32, i32* %arrayidx2, align 4
28 %add3 = add nsw i32 %add, %2
29 %arrayidx4 = getelementptr inbounds i32, i32* %E, i64 %i.016
30 %3 = load i32, i32* %arrayidx4, align 4
31 %add5 = add nsw i32 %add3, %3
32 %arrayidx6 = getelementptr inbounds i32, i32* %F, i64 %i.016
33 %4 = load i32, i32* %arrayidx6, align 4
34 %add7 = add nsw i32 %add5, %4
35 %arrayidx8 = getelementptr inbounds i32, i32* %out, i64 %i.016
36 store i32 %add7, i32* %arrayidx8, align 4
37 %inc = add i64 %i.016, 1
38 %exitcond = icmp eq i64 %inc, 256
39 br i1 %exitcond, label %for.end, label %for.body
41 for.end: ; preds = %for.body
45 ; We are not vectorizing with 12 runtime checks.
46 ;CHECK-LABEL: func2x6(
49 define i32 @func2x6(i32* nocapture %out, i32* nocapture %out2, i32* nocapture %A, i32* nocapture %B, i32* nocapture %C, i32* nocapture %D, i32* nocapture %E, i32* nocapture %F) {
53 for.body: ; preds = %for.body, %entry
54 %i.037 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
55 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %i.037
56 %0 = load i32, i32* %arrayidx, align 4
57 %arrayidx1 = getelementptr inbounds i32, i32* %B, i64 %i.037
58 %1 = load i32, i32* %arrayidx1, align 4
59 %add = add nsw i32 %1, %0
60 %arrayidx2 = getelementptr inbounds i32, i32* %C, i64 %i.037
61 %2 = load i32, i32* %arrayidx2, align 4
62 %add3 = add nsw i32 %add, %2
63 %arrayidx4 = getelementptr inbounds i32, i32* %E, i64 %i.037
64 %3 = load i32, i32* %arrayidx4, align 4
65 %add5 = add nsw i32 %add3, %3
66 %arrayidx6 = getelementptr inbounds i32, i32* %F, i64 %i.037
67 %4 = load i32, i32* %arrayidx6, align 4
68 %add7 = add nsw i32 %add5, %4
69 %arrayidx8 = getelementptr inbounds i32, i32* %out, i64 %i.037
70 store i32 %add7, i32* %arrayidx8, align 4
71 %5 = load i32, i32* %arrayidx, align 4
72 %6 = load i32, i32* %arrayidx1, align 4
73 %add11 = add nsw i32 %6, %5
74 %7 = load i32, i32* %arrayidx2, align 4
75 %add13 = add nsw i32 %add11, %7
76 %8 = load i32, i32* %arrayidx4, align 4
77 %add15 = add nsw i32 %add13, %8
78 %9 = load i32, i32* %arrayidx6, align 4
79 %add17 = add nsw i32 %add15, %9
80 %arrayidx18 = getelementptr inbounds i32, i32* %out2, i64 %i.037
81 store i32 %add17, i32* %arrayidx18, align 4
82 %inc = add i64 %i.037, 1
83 %exitcond = icmp eq i64 %inc, 256
84 br i1 %exitcond, label %for.end, label %for.body
86 for.end: ; preds = %for.body