1 ; RUN: opt -passes=loop-vectorize -force-vector-width=8 -force-vector-interleave=2 -disable-output -debug -S %s 2>&1 | FileCheck --check-prefixes=CHECK %s
3 target datalayout = "e-m:o-i64:64-i128:128-n32:64-S128"
7 ; Check if the vector loop condition can be simplified to true for a given
9 define void @test_tc_less_than_16(ptr %A, i64 %N) {
10 ; CHECK: LV: Scalarizing: %cmp =
11 ; CHECK: VPlan 'Initial VPlan for VF={8},UF>=1' {
12 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
13 ; CHECK-NEXT: Live-in vp<[[VTC:%.+]]> = vector-trip-count
14 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
16 ; CHECK-NEXT: ir-bb<entry>:
17 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (zext i4 (trunc i64 %N to i4) to i64)
18 ; CHECK-NEXT: No successors
20 ; CHECK-NEXT: vector.ph:
21 ; CHECK-NEXT: Successor(s): vector loop
23 ; CHECK-NEXT: <x1> vector loop: {
24 ; CHECK-NEXT: vector.body:
25 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION ir<0>, vp<[[CAN_IV_NEXT:%.+]]>
26 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
27 ; CHECK-NEXT: EMIT vp<[[PADD:%.+]]> = ptradd ir<%A>, vp<[[STEPS]]>
28 ; CHECK-NEXT: vp<[[VPTR:%.]]> = vector-pointer vp<[[PADD]]>
29 ; CHECK-NEXT: WIDEN ir<%l> = load vp<[[VPTR]]>
30 ; CHECK-NEXT: WIDEN ir<%add> = add nsw ir<%l>, ir<10>
31 ; CHECK-NEXT: vp<[[VPTR2:%.+]]> = vector-pointer vp<[[PADD]]>
32 ; CHECK-NEXT: WIDEN store vp<[[VPTR2]]>, ir<%add>
33 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT]]> = add nuw vp<[[CAN_IV:%.+]]>, vp<[[VFxUF]]>
34 ; CHECK-NEXT: EMIT branch-on-count vp<[[CAN_IV_NEXT]]>, vp<[[VTC]]>
35 ; CHECK-NEXT: No successors
37 ; CHECK-NEXT: Successor(s): middle.block
39 ; CHECK-NEXT: middle.block:
40 ; CHECK-NEXT: EMIT vp<[[C:%.+]]> = icmp eq vp<[[TC]]>, vp<[[VTC]]>
41 ; CHECK-NEXT: EMIT branch-on-cond vp<[[C]]>
42 ; CHECK-NEXT: Successor(s): ir-bb<exit>, scalar.ph
44 ; CHECK-NEXT: ir-bb<exit>:
45 ; CHECK-NEXT: No successors
47 ; CHECK-NEXT: scalar.ph:
48 ; CHECK-NEXT: No successors
51 ; CHECK: Executing best plan with VF=8, UF=2
52 ; CHECK-NEXT: VPlan 'Final VPlan for VF={8},UF={2}' {
53 ; CHECK-NEXT: Live-in vp<[[VFxUF:%.+]]> = VF * UF
54 ; CHECK-NEXT: Live-in vp<[[VTC:%.+]]> = vector-trip-count
55 ; CHECK-NEXT: vp<[[TC:%.+]]> = original trip-count
57 ; CHECK-NEXT: ir-bb<entry>:
58 ; CHECK-NEXT: EMIT vp<[[TC]]> = EXPAND SCEV (zext i4 (trunc i64 %N to i4) to i64)
59 ; CHECK-NEXT: No successors
61 ; CHECK-NEXT: vector.ph:
62 ; CHECK-NEXT: Successor(s): vector loop
64 ; CHECK-NEXT: <x1> vector loop: {
65 ; CHECK-NEXT: vector.body:
66 ; CHECK-NEXT: EMIT vp<[[CAN_IV:%.+]]> = CANONICAL-INDUCTION ir<0>, vp<[[CAN_IV_NEXT:%.+]]>
67 ; CHECK-NEXT: vp<[[STEPS:%.+]]> = SCALAR-STEPS vp<[[CAN_IV]]>, ir<1>
68 ; CHECK-NEXT: EMIT vp<[[PADD:%.+]]> = ptradd ir<%A>, vp<[[STEPS]]>
69 ; CHECK-NEXT: vp<[[VPTR:%.]]> = vector-pointer vp<[[PADD]]>
70 ; CHECK-NEXT: WIDEN ir<%l> = load vp<[[VPTR]]>
71 ; CHECK-NEXT: WIDEN ir<%add> = add nsw ir<%l>, ir<10>
72 ; CHECK-NEXT: vp<[[VPTR2:%.+]]> = vector-pointer vp<[[PADD]]>
73 ; CHECK-NEXT: WIDEN store vp<[[VPTR2]]>, ir<%add>
74 ; CHECK-NEXT: EMIT vp<[[CAN_IV_NEXT]]> = add nuw vp<[[CAN_IV:%.+]]>, vp<[[VFxUF]]>
75 ; CHECK-NEXT: EMIT branch-on-cond ir<true>
76 ; CHECK-NEXT: No successors
78 ; CHECK-NEXT: Successor(s): middle.block
80 ; CHECK-NEXT: middle.block:
81 ; CHECK-NEXT: EMIT vp<[[C:%.+]]> = icmp eq vp<[[TC]]>, vp<[[VTC]]>
82 ; CHECK-NEXT: EMIT branch-on-cond vp<[[C]]>
83 ; CHECK-NEXT: Successor(s): ir-bb<exit>, scalar.ph
85 ; CHECK-NEXT: ir-bb<exit>:
86 ; CHECK-NEXT: No successors
88 ; CHECK-NEXT: scalar.ph:
89 ; CHECK-NEXT: No successors
97 %iv = phi i64 [ %and, %entry ], [ %iv.next, %loop ]
98 %p.src = phi ptr [ %A, %entry ], [ %p.src.next, %loop ]
99 %p.src.next = getelementptr inbounds i8, ptr %p.src, i64 1
100 %l = load i8, ptr %p.src, align 1
101 %add = add nsw i8 %l, 10
102 store i8 %add, ptr %p.src
103 %iv.next = add nsw i64 %iv, -1
104 %cmp = icmp eq i64 %iv.next, 0
105 br i1 %cmp, label %exit, label %loop