3 ; RUN: opt -passes=loop-vectorize -debug-only=loop-vectorize -force-vector-width=4 \
4 ; RUN: -force-tail-folding-style=data-with-evl \
5 ; RUN: -prefer-predicate-over-epilogue=predicate-dont-vectorize \
6 ; RUN: -mtriple=x86_64 -mattr=+avx512f -disable-output < %s 2>&1 | FileCheck --check-prefix=IF-EVL %s
8 ; RUN: opt -passes=loop-vectorize -debug-only=loop-vectorize -force-vector-width=4 \
9 ; RUN: -force-tail-folding-style=none \
10 ; RUN: -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue \
11 ; RUN: -mtriple=x86_64 -mattr=+avx512f -disable-output < %s 2>&1 | FileCheck --check-prefix=NO-VP %s
13 define void @foo(ptr noalias %a, ptr noalias %b, ptr noalias %c, i64 %N) {
14 ; IF-EVL: VPlan 'Initial VPlan for VF={4},UF>=1' {
15 ; IF-EVL-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
16 ; IF-EVL-NEXT: Live-in vp<[[VTC:%[0-9]+]]> = vector-trip-count
17 ; IF-EVL-NEXT: Live-in vp<[[BETC:%[0-9]+]]> = backedge-taken count
18 ; IF-EVL-NEXT: Live-in ir<%N> = original trip-count
21 ; IF-EVL-NEXT: Successor(s): vector loop
23 ; IF-EVL-NEXT: <x1> vector loop: {
24 ; IF-EVL-NEXT: vector.body:
25 ; IF-EVL-NEXT: EMIT vp<[[IV:%[0-9]+]]> = CANONICAL-INDUCTION
26 ; IF-EVL-NEXT: vp<[[ST:%[0-9]+]]> = SCALAR-STEPS vp<[[IV]]>, ir<1>
27 ; IF-EVL-NEXT: EMIT vp<[[VIV:%[0-9]+]]> = WIDEN-CANONICAL-INDUCTION vp<[[IV]]>
28 ; IF-EVL-NEXT: EMIT vp<[[MASK:%[0-9]+]]> = icmp ule vp<[[VIV]]>, vp<[[BETC]]>
29 ; IF-EVL-NEXT: CLONE ir<[[GEP1:%.+]]> = getelementptr inbounds ir<%b>, vp<[[ST]]>
30 ; IF-EVL-NEXT: vp<[[PTR1:%[0-9]+]]> = vector-pointer ir<[[GEP1]]>
31 ; IF-EVL-NEXT: WIDEN ir<[[LD1:%.+]]> = load vp<[[PTR1]]>, vp<[[MASK]]>
32 ; IF-EVL-NEXT: CLONE ir<[[GEP2:%.+]]> = getelementptr inbounds ir<%c>, vp<[[ST]]>
33 ; IF-EVL-NEXT: vp<[[PTR2:%[0-9]+]]> = vector-pointer ir<[[GEP2]]>
34 ; IF-EVL-NEXT: WIDEN ir<[[LD2:%.+]]> = load vp<[[PTR2]]>, vp<[[MASK]]>
35 ; IF-EVL-NEXT: WIDEN ir<[[ADD:%.+]]> = add nsw ir<[[LD2]]>, ir<[[LD1]]>
36 ; IF-EVL-NEXT: CLONE ir<[[GEP3:%.+]]> = getelementptr inbounds ir<%a>, vp<[[ST]]>
37 ; IF-EVL-NEXT: vp<[[PTR3:%[0-9]+]]> = vector-pointer ir<[[GEP3]]>
38 ; IF-EVL-NEXT: WIDEN store vp<[[PTR3]]>, ir<[[ADD]]>, vp<[[MASK]]>
39 ; IF-EVL-NEXT: EMIT vp<[[IV_NEXT:%.+]]> = add vp<[[IV]]>, vp<[[VFUF]]>
40 ; IF-EVL-NEXT: EMIT branch-on-count vp<[[IV_NEXT]]>, vp<[[VTC]]>
41 ; IF-EVL-NEXT: No successors
44 ; NO-VP: VPlan 'Initial VPlan for VF={4},UF>=1' {
45 ; NO-VP-NEXT: Live-in vp<[[VFUF:%[0-9]+]]> = VF * UF
46 ; NO-VP-NEXT: Live-in vp<[[VTC:%[0-9]+]]> = vector-trip-count
47 ; NO-VP-NEXT: Live-in ir<%N> = original trip-count
50 ; NO-VP-NEXT: Successor(s): vector loop
52 ; NO-VP-NEXT: <x1> vector loop: {
53 ; NO-VP-NEXT: vector.body:
54 ; NO-VP-NEXT: EMIT vp<[[IV:%[0-9]+]]> = CANONICAL-INDUCTION
55 ; NO-VP-NEXT: vp<[[ST:%[0-9]+]]> = SCALAR-STEPS vp<[[IV]]>, ir<1>
56 ; NO-VP-NEXT: CLONE ir<[[GEP1:%.+]]> = getelementptr inbounds ir<%b>, vp<[[ST]]>
57 ; NO-VP-NEXT: vp<[[PTR1:%[0-9]+]]> = vector-pointer ir<[[GEP1]]>
58 ; NO-VP-NEXT: WIDEN ir<[[LD1:%.+]]> = load vp<[[PTR1]]>
59 ; NO-VP-NEXT: CLONE ir<[[GEP2:%.+]]> = getelementptr inbounds ir<%c>, vp<[[ST]]>
60 ; NO-VP-NEXT: vp<[[PTR2:%[0-9]+]]> = vector-pointer ir<[[GEP2]]>
61 ; NO-VP-NEXT: WIDEN ir<[[LD2:%.+]]> = load vp<[[PTR2]]>
62 ; NO-VP-NEXT: WIDEN ir<[[ADD:%.+]]> = add nsw ir<[[LD2]]>, ir<[[LD1]]>
63 ; NO-VP-NEXT: CLONE ir<[[GEP3:%.+]]> = getelementptr inbounds ir<%a>, vp<[[ST]]>
64 ; NO-VP-NEXT: vp<[[PTR3:%[0-9]+]]> = vector-pointer ir<[[GEP3]]>
65 ; NO-VP-NEXT: WIDEN store vp<[[PTR3]]>, ir<[[ADD]]>
66 ; NO-VP-NEXT: EMIT vp<[[IV_NEXT:%.+]]> = add nuw vp<[[IV]]>, vp<[[VFUF]]>
67 ; NO-VP-NEXT: EMIT branch-on-count vp<[[IV_NEXT]]>, vp<[[VTC]]>
68 ; NO-VP-NEXT: No successors
75 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
76 %arrayidx = getelementptr inbounds i32, ptr %b, i64 %iv
77 %0 = load i32, ptr %arrayidx, align 4
78 %arrayidx2 = getelementptr inbounds i32, ptr %c, i64 %iv
79 %1 = load i32, ptr %arrayidx2, align 4
80 %add = add nsw i32 %1, %0
81 %arrayidx4 = getelementptr inbounds i32, ptr %a, i64 %iv
82 store i32 %add, ptr %arrayidx4, align 4
83 %iv.next = add nuw nsw i64 %iv, 1
84 %exitcond.not = icmp eq i64 %iv.next, %N
85 br i1 %exitcond.not, label %for.cond.cleanup, label %for.body