1 ; RUN: opt < %s -mtriple=x86_64-unknown-unknown -mattr=+sse2 -debug-only=loop-vectorize -loop-vectorize -vectorizer-maximize-bandwidth 2>&1 | FileCheck %s
4 @a = global [1024 x i8] zeroinitializer, align 16
5 @b = global [1024 x i8] zeroinitializer, align 16
8 ; This function has a loop of SAD pattern. Here we check when VF = 16 the
9 ; register usage doesn't exceed 16.
12 ; CHECK: LV(REG): VF = 4
13 ; CHECK-NEXT: LV(REG): Found max usage: 4
14 ; CHECK: LV(REG): VF = 8
15 ; CHECK-NEXT: LV(REG): Found max usage: 7
16 ; CHECK: LV(REG): VF = 16
17 ; CHECK-NEXT: LV(REG): Found max usage: 13
23 %add.lcssa = phi i32 [ %add, %for.body ]
27 %indvars.iv = phi i64 [ 0, %entry ], [ %indvars.iv.next, %for.body ]
28 %s.015 = phi i32 [ 0, %entry ], [ %add, %for.body ]
29 %arrayidx = getelementptr inbounds [1024 x i8], [1024 x i8]* @a, i64 0, i64 %indvars.iv
30 %0 = load i8, i8* %arrayidx, align 1
31 %conv = zext i8 %0 to i32
32 %arrayidx2 = getelementptr inbounds [1024 x i8], [1024 x i8]* @b, i64 0, i64 %indvars.iv
33 %1 = load i8, i8* %arrayidx2, align 1
34 %conv3 = zext i8 %1 to i32
35 %sub = sub nsw i32 %conv, %conv3
36 %ispos = icmp sgt i32 %sub, -1
37 %neg = sub nsw i32 0, %sub
38 %2 = select i1 %ispos, i32 %sub, i32 %neg
39 %add = add nsw i32 %2, %s.015
40 %indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
41 %exitcond = icmp eq i64 %indvars.iv.next, 1024
42 br i1 %exitcond, label %for.cond.cleanup, label %for.body
45 define i64 @bar(i64* nocapture %a) {
47 ; CHECK: LV(REG): VF = 2
48 ; CHECK: LV(REG): Found max usage: 4
54 %add2.lcssa = phi i64 [ %add2, %for.body ]
58 %i.012 = phi i64 [ 0, %entry ], [ %inc, %for.body ]
59 %s.011 = phi i64 [ 0, %entry ], [ %add2, %for.body ]
60 %arrayidx = getelementptr inbounds i64, i64* %a, i64 %i.012
61 %0 = load i64, i64* %arrayidx, align 8
62 %add = add nsw i64 %0, %i.012
63 store i64 %add, i64* %arrayidx, align 8
64 %add2 = add nsw i64 %add, %s.011
65 %inc = add nuw nsw i64 %i.012, 1
66 %exitcond = icmp eq i64 %inc, 1024
67 br i1 %exitcond, label %for.cond.cleanup, label %for.body