1 ; RUN: opt < %s -loop-vectorize -force-vector-interleave=1 -force-vector-width=4 -S | FileCheck %s
2 ; We vectorize the inner loop, so we have to put it in LCSSA form.
3 ; However, there's no reason to touch the outer loop.
6 ; CHECK-LABEL: for.end.inner.loopexit:
7 ; CHECK: %[[LCSSAPHI:.*]] = phi i64 [ %indvars.iv, %for.body.inner ], [ %{{.*}}, %middle.block ]
8 ; CHECK: store i64 %[[LCSSAPHI]], i64* %O1, align 4
9 ; CHECK-LABEL: for.end.outer.loopexit
10 ; CHECK: store i64 %indvars.outer, i64* %O2, align 4
13 define i64 @foo(i32* nocapture %A, i32* nocapture %B, i64 %n, i64 %m, i64* %O1, i64* %O2) {
15 %cmp = icmp sgt i64 %n, 0
16 br i1 %cmp, label %for.body.outer.preheader, label %for.end.outer
18 for.body.outer.preheader: ; preds = %entry
19 br label %for.body.outer
21 for.body.outer: ; preds = %for.body.outer.preheader, %for.end.inner
22 %indvars.outer = phi i64 [ %indvars.outer.next, %for.end.inner ], [ 0, %for.body.outer.preheader ]
23 %cmp2 = icmp sgt i64 %m, 0
24 br i1 %cmp2, label %for.body.inner.preheader, label %for.end.inner
26 for.body.inner.preheader: ; preds = %for.body.outer
27 br label %for.body.inner
29 for.body.inner: ; preds = %for.body.inner.preheader, %for.body.inner
30 %indvars.iv = phi i64 [ %indvars.iv.next, %for.body.inner ], [ 0, %for.body.inner.preheader ]
31 %arrayidx = getelementptr inbounds i32, i32* %A, i64 %indvars.iv
32 %v = load i32, i32* %arrayidx, align 4
33 %arrayidx2 = getelementptr inbounds i32, i32* %B, i64 %indvars.iv
34 store i32 %v, i32* %arrayidx2, align 4
35 %indvars.iv.next = add i64 %indvars.iv, 1
36 %exitcond = icmp eq i64 %indvars.iv, %n
37 br i1 %exitcond, label %for.end.inner.loopexit, label %for.body.inner
39 for.end.inner.loopexit: ; preds = %for.body.inner
40 store i64 %indvars.iv, i64 *%O1, align 4
41 br label %for.end.inner
43 for.end.inner: ; preds = %for.end.inner.loopexit, %for.body.outer
44 %indvars.outer.next = add i64 %indvars.outer, 1
45 %exitcond.outer = icmp eq i64 %indvars.outer, %m
46 br i1 %exitcond.outer, label %for.end.outer.loopexit, label %for.body.outer
48 for.end.outer.loopexit: ; preds = %for.end.inner
49 store i64 %indvars.outer, i64 *%O2, align 4
50 br label %for.end.outer
52 for.end.outer: ; preds = %for.end.outer.loopexit, %entry