1; RUN: opt -loop-vectorize -S < %s | FileCheck %s
2target datalayout = "e-m:e-i64:64-f80:128-n8:16:32:64-S128"
3target triple = "x86_64-unknown-linux-gnu"
4
5; Function Attrs: norecurse nounwind uwtable
6define void @Test(i32* nocapture %res, i32* nocapture readnone %c, i32* nocapture readonly %d, i32* nocapture readonly %p) #0 {
7entry:
8  br label %for.body
9
10; CHECK-LABEL: @Test
11; CHECK: <4 x i32>
12
13for.body:                                         ; preds = %cond.end, %entry
14  %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %cond.end ]
15  %arrayidx = getelementptr inbounds i32, i32* %p, i64 %indvars.iv
16  %0 = load i32, i32* %arrayidx, align 4, !llvm.mem.parallel_loop_access !0
17  %cmp1 = icmp eq i32 %0, 0
18  %arrayidx3 = getelementptr inbounds i32, i32* %res, i64 %indvars.iv
19  %1 = load i32, i32* %arrayidx3, align 4, !llvm.mem.parallel_loop_access !0
20  br i1 %cmp1, label %cond.end, label %cond.false
21
22cond.false:                                       ; preds = %for.body
23  %arrayidx7 = getelementptr inbounds i32, i32* %d, i64 %indvars.iv
24  %2 = load i32, i32* %arrayidx7, align 4, !llvm.mem.parallel_loop_access !0
25  %add = add nsw i32 %2, %1
26  br label %cond.end
27
28cond.end:                                         ; preds = %for.body, %cond.false
29  %cond = phi i32 [ %add, %cond.false ], [ %1, %for.body ]
30  store i32 %cond, i32* %arrayidx3, align 4, !llvm.mem.parallel_loop_access !0
31  %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
32  %exitcond = icmp eq i64 %indvars.iv.next, 16
33  br i1 %exitcond, label %for.end, label %for.body, !llvm.loop !0
34
35for.end:                                          ; preds = %cond.end
36  ret void
37}
38
39attributes #0 = { norecurse nounwind uwtable "target-cpu"="x86-64" "target-features"="+fxsr,+mmx,+sse,+sse2,+x87" }
40
41!0 = distinct !{!0}
42