2 ; RUN: opt -mattr=+neon,+dotprod -passes=loop-vectorize -debug-only=loop-vectorize -force-vector-interleave=1 -disable-output %s 2>&1 | FileCheck %s
4 target datalayout = "e-m:e-i8:8:32-i16:16:32-i64:64-i128:128-n32:64-S128"
5 target triple = "aarch64-none-unknown-elf"
7 ; Tests for printing VPlans that are enabled under AArch64
9 define i32 @print_partial_reduction(ptr %a, ptr %b) {
10 ; CHECK: VPlan 'Initial VPlan for VF={8,16},UF>=1' {
11 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.]]> = VF * UF
12 ; CHECK-NEXT: Live-in vp<[[VEC_TC:%.+]]> = vector-trip-count
13 ; CHECK-NEXT: Live-in ir<1024> = original trip-count
15 ; CHECK-NEXT: ir-bb<entry>:
16 ; CHECK-NEXT: Successor(s): vector.ph
18 ; CHECK-NEXT: vector.ph:
19 ; CHECK-NEXT: Successor(s): vector loop
21 ; CHECK-NEXT: <x1> vector loop: {
22 ; CHECK-NEXT: vector.body:
23 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION ir<0>, vp<[[CAN_IV_NEXT:%.+]]>
24 ; CHECK-NEXT: WIDEN-REDUCTION-PHI ir<[[ACC:%.+]]> = phi ir<0>, ir<[[REDUCE:%.+]]> (VF scaled by 1/4)
25 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
26 ; CHECK-NEXT: CLONE ir<%gep.a> = getelementptr ir<%a>, vp<[[STEPS]]>
27 ; CHECK-NEXT: vp<[[PTR_A:%.+]]> = vector-pointer ir<%gep.a>
28 ; CHECK-NEXT: WIDEN ir<%load.a> = load vp<[[PTR_A]]>
29 ; CHECK-NEXT: WIDEN-CAST ir<%ext.a> = zext ir<%load.a> to i32
30 ; CHECK-NEXT: CLONE ir<%gep.b> = getelementptr ir<%b>, vp<[[STEPS]]>
31 ; CHECK-NEXT: vp<[[PTR_B:%.+]]> = vector-pointer ir<%gep.b>
32 ; CHECK-NEXT: WIDEN ir<%load.b> = load vp<[[PTR_B]]>
33 ; CHECK-NEXT: WIDEN-CAST ir<%ext.b> = zext ir<%load.b> to i32
34 ; CHECK-NEXT: WIDEN ir<%mul> = mul ir<%ext.b>, ir<%ext.a>
35 ; CHECK-NEXT: PARTIAL-REDUCE ir<[[REDUCE]]> = add ir<%mul>, ir<[[ACC]]>
36 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT]]> = add nuw vp<[[CAN_IV]]>, vp<[[VFxUF]]>
37 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VEC_TC]]>
38 ; CHECK-NEXT: No successors
40 ; CHECK-NEXT: Successor(s): middle.block
42 ; CHECK-NEXT: middle.block:
43 ; CHECK-NEXT: EMIT vp<[[RED_RESULT:%.+]]> = compute-reduction-result ir<[[ACC]]>, ir<[[REDUCE]]>
44 ; CHECK-NEXT: EMIT vp<[[EXTRACT:%.+]]> = extract-from-end vp<[[RED_RESULT]]>, ir<1>
45 ; CHECK-NEXT: EMIT vp<[[CMP:%.+]]> = icmp eq ir<1024>, vp<%1>
46 ; CHECK-NEXT: EMIT branch-on-cond vp<[[CMP]]>
47 ; CHECK-NEXT: Successor(s): ir-bb<exit>, scalar.ph
49 ; CHECK-NEXT: scalar.ph:
50 ; CHECK-NEXT: EMIT vp<%bc.resume.val> = resume-phi vp<[[VEC_TC]]>, ir<0>
51 ; CHECK-NEXT: EMIT vp<%bc.merge.rdx> = resume-phi vp<[[RED_RESULT]]>, ir<0>
52 ; CHECK-NEXT: Successor(s): ir-bb<for.body>
54 ; CHECK-NEXT: ir-bb<for.body>:
55 ; CHECK-NEXT: IR %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
56 ; CHECK-NEXT: IR %accum = phi i32 [ 0, %entry ], [ %add, %for.body ] (extra operand: vp<%bc.merge.rdx> from scalar.ph)
57 ; CHECK-NEXT: IR %gep.a = getelementptr i8, ptr %a, i64 %iv
58 ; CHECK-NEXT: IR %load.a = load i8, ptr %gep.a, align 1
59 ; CHECK-NEXT: IR %ext.a = zext i8 %load.a to i32
60 ; CHECK-NEXT: IR %gep.b = getelementptr i8, ptr %b, i64 %iv
61 ; CHECK-NEXT: IR %load.b = load i8, ptr %gep.b, align 1
62 ; CHECK-NEXT: IR %ext.b = zext i8 %load.b to i32
63 ; CHECK-NEXT: IR %mul = mul i32 %ext.b, %ext.a
64 ; CHECK-NEXT: IR %add = add i32 %mul, %accum
65 ; CHECK-NEXT: IR %iv.next = add i64 %iv, 1
66 ; CHECK-NEXT: IR %exitcond.not = icmp eq i64 %iv.next, 1024
67 ; CHECK-NEXT: No successors
69 ; CHECK-NEXT: ir-bb<exit>:
70 ; CHECK-NEXT: IR %add.lcssa = phi i32 [ %add, %for.body ] (extra operand: vp<[[EXTRACT]]> from middle.block)
71 ; CHECK-NEXT: No successors
77 for.body: ; preds = %for.body, %entry
78 %iv = phi i64 [ 0, %entry ], [ %iv.next, %for.body ]
79 %accum = phi i32 [ 0, %entry ], [ %add, %for.body ]
80 %gep.a = getelementptr i8, ptr %a, i64 %iv
81 %load.a = load i8, ptr %gep.a, align 1
82 %ext.a = zext i8 %load.a to i32
83 %gep.b = getelementptr i8, ptr %b, i64 %iv
84 %load.b = load i8, ptr %gep.b, align 1
85 %ext.b = zext i8 %load.b to i32
86 %mul = mul i32 %ext.b, %ext.a
87 %add = add i32 %mul, %accum
88 %iv.next = add i64 %iv, 1
89 %exitcond.not = icmp eq i64 %iv.next, 1024
90 br i1 %exitcond.not, label %exit, label %for.body