1 ; RUN: opt -basicaa -scoped-noalias -loop-vectorize -licm -force-vector-width=2 \
2 ; RUN: -force-vector-interleave=1 -S < %s | FileCheck %s
4 target datalayout = "e-m:o-i64:64-f80:128-n8:16:32:64-S128"
6 ; In order to vectorize the inner loop, it needs to be versioned with
7 ; memchecks between {A} x {B, C} first:
9 ; for (i = 0; i < n; i++)
10 ; for (j = 0; j < m; j++)
11 ; A[j] += B[i] + C[j];
13 ; Since in the versioned vector loop A and B can no longer alias, B[i] can be
14 ; LICM'ed from the inner loop.
17 define void @f(i32* %a, i32* %b, i32* %c) {
22 %i.2 = phi i64 [ 0, %entry ], [ %i, %inner.end ]
23 %arrayidxB = getelementptr inbounds i32, i32* %b, i64 %i.2
28 ; CHECK: load i32, i32* %arrayidxB,
29 ; CHECK: br label %vector.body
33 %j.2 = phi i64 [ 0, %inner.ph ], [ %j, %inner ]
35 %arrayidxA = getelementptr inbounds i32, i32* %a, i64 %j.2
36 %loadA = load i32, i32* %arrayidxA, align 4
38 %loadB = load i32, i32* %arrayidxB, align 4
40 %arrayidxC = getelementptr inbounds i32, i32* %c, i64 %j.2
41 %loadC = load i32, i32* %arrayidxC, align 4
43 %add = add nuw i32 %loadA, %loadB
44 %add2 = add nuw i32 %add, %loadC
46 store i32 %add2, i32* %arrayidxA, align 4
48 %j = add nuw nsw i64 %j.2, 1
49 %cond1 = icmp eq i64 %j, 20
50 br i1 %cond1, label %inner.end, label %inner
53 %i = add nuw nsw i64 %i.2, 1
54 %cond2 = icmp eq i64 %i, 30
55 br i1 %cond2, label %outer.end, label %outer