Skip to content

Commit f7544ea

Browse files
committed
[LV][EVL][Test] Prepare test for adding select Recipe
1 parent f41f6ea commit f7544ea

File tree

1 file changed

+101
-0
lines changed

1 file changed

+101
-0
lines changed
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
; REQUIRES: asserts
2+
3+
; RUN: opt -passes=loop-vectorize -debug-only=loop-vectorize \
4+
; RUN: -force-tail-folding-style=data-with-evl \
5+
; RUN: -prefer-predicate-over-epilogue=predicate-dont-vectorize \
6+
; RUN: -mtriple=riscv64 -mattr=+v -riscv-v-vector-bits-max=128 -disable-output < %s 2>&1 | FileCheck --check-prefix=IF-EVL %s
7+
8+
; RUN: opt -passes=loop-vectorize -debug-only=loop-vectorize \
9+
; RUN: -force-tail-folding-style=none \
10+
; RUN: -prefer-predicate-over-epilogue=predicate-else-scalar-epilogue \
11+
; RUN: -mtriple=riscv64 -mattr=+v -riscv-v-vector-bits-max=128 -disable-output < %s 2>&1 | FileCheck --check-prefix=NO-VP %s
12+
13+
define void @vp_select(ptr noalias %a, ptr noalias %b, ptr noalias %c, i64 %N) {
14+
; IF-EVL: VPlan 'Final VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF={1}' {
15+
; IF-EVL-NEXT: Live-in vp<%0> = VF * UF
16+
; IF-EVL-NEXT: Live-in vp<%1> = vector-trip-count
17+
; IF-EVL-NEXT: Live-in ir<%N> = original trip-count
18+
19+
; IF-EVL: vector.ph:
20+
; IF-EVL-NEXT: Successor(s): vector loop
21+
22+
; IF-EVL: <x1> vector loop: {
23+
; IF-EVL-NEXT: vector.body:
24+
; IF-EVL-NEXT: EMIT vp<%3> = CANONICAL-INDUCTION ir<0>, vp<%12>
25+
; IF-EVL-NEXT: EXPLICIT-VECTOR-LENGTH-BASED-IV-PHI vp<%4> = phi ir<0>, vp<%11>
26+
; IF-EVL-NEXT: EMIT vp<%5> = EXPLICIT-VECTOR-LENGTH vp<%4>, ir<%N>
27+
; IF-EVL-NEXT: vp<%6> = SCALAR-STEPS vp<%4>, ir<1>
28+
; IF-EVL-NEXT: CLONE ir<%arrayidx> = getelementptr inbounds ir<%b>, vp<%6>
29+
; IF-EVL-NEXT: vp<%7> = vector-pointer ir<%arrayidx>
30+
; IF-EVL-NEXT: WIDEN ir<%0> = vp.load vp<%7>, vp<%5>
31+
; IF-EVL-NEXT: CLONE ir<%arrayidx3> = getelementptr inbounds ir<%c>, vp<%6>
32+
; IF-EVL-NEXT: vp<%8> = vector-pointer ir<%arrayidx3>
33+
; IF-EVL-NEXT: WIDEN ir<%1> = vp.load vp<%8>, vp<%5>
34+
; IF-EVL-NEXT: WIDEN ir<%cmp4> = icmp sgt ir<%0>, ir<%1>
35+
; IF-EVL-NEXT: WIDEN ir<%2> = vp.sub ir<0>, ir<%1>, vp<%5>
36+
; IF-EVL-NEXT: WIDEN-SELECT ir<%cond.p> = select ir<%cmp4>, ir<%1>, ir<%2>
37+
; IF-EVL-NEXT: WIDEN ir<%cond> = vp.add ir<%cond.p>, ir<%0>, vp<%5>
38+
; IF-EVL-NEXT: CLONE ir<%arrayidx15> = getelementptr inbounds ir<%a>, vp<%6>
39+
; IF-EVL-NEXT: vp<%9> = vector-pointer ir<%arrayidx15>
40+
; IF-EVL-NEXT: WIDEN vp.store vp<%9>, ir<%cond>, vp<%5>
41+
; IF-EVL-NEXT: SCALAR-CAST vp<%10> = zext vp<%5> to i64
42+
; IF-EVL-NEXT: EMIT vp<%11> = add vp<%10>, vp<%4>
43+
; IF-EVL-NEXT: EMIT vp<%12> = add vp<%3>, vp<%0>
44+
; IF-EVL-NEXT: EMIT branch-on-count vp<%12>, vp<%1>
45+
; IF-EVL-NEXT: No successors
46+
; IF-EVL-NEXT: }
47+
48+
; NO-VP: VPlan 'Final VPlan for VF={vscale x 1,vscale x 2,vscale x 4},UF>=1' {
49+
; NO-VP-NEXT: Live-in vp<%0> = VF * UF
50+
; NO-VP-NEXT: Live-in vp<%1> = vector-trip-count
51+
; NO-VP-NEXT: Live-in ir<%N> = original trip-count
52+
53+
; NO-VP: vector.ph:
54+
; NO-VP-NEXT: Successor(s): vector loop
55+
56+
; NO-VP: <x1> vector loop: {
57+
; NO-VP-NEXT: vector.body:
58+
; NO-VP-NEXT: EMIT vp<%2> = CANONICAL-INDUCTION ir<0>, vp<%7>
59+
; NO-VP-NEXT: vp<%3> = SCALAR-STEPS vp<%2>, ir<1>
60+
; NO-VP-NEXT: CLONE ir<%arrayidx> = getelementptr inbounds ir<%b>, vp<%3>
61+
; NO-VP-NEXT: vp<%4> = vector-pointer ir<%arrayidx>
62+
; NO-VP-NEXT: WIDEN ir<%0> = load vp<%4>
63+
; NO-VP-NEXT: CLONE ir<%arrayidx3> = getelementptr inbounds ir<%c>, vp<%3>
64+
; NO-VP-NEXT: vp<%5> = vector-pointer ir<%arrayidx3>
65+
; NO-VP-NEXT: WIDEN ir<%1> = load vp<%5>
66+
; NO-VP-NEXT: WIDEN ir<%cmp4> = icmp sgt ir<%0>, ir<%1>
67+
; NO-VP-NEXT: WIDEN ir<%2> = sub ir<0>, ir<%1>
68+
; NO-VP-NEXT: WIDEN-SELECT ir<%cond.p> = select ir<%cmp4>, ir<%1>, ir<%2>
69+
; NO-VP-NEXT: WIDEN ir<%cond> = add ir<%cond.p>, ir<%0>
70+
; NO-VP-NEXT: CLONE ir<%arrayidx15> = getelementptr inbounds ir<%a>, vp<%3>
71+
; NO-VP-NEXT: vp<%6> = vector-pointer ir<%arrayidx15>
72+
; NO-VP-NEXT: WIDEN store vp<%6>, ir<%cond>
73+
; NO-VP-NEXT: EMIT vp<%7> = add nuw vp<%2>, vp<%0>
74+
; NO-VP-NEXT: EMIT branch-on-count vp<%7>, vp<%1>
75+
; NO-VP-NEXT: No successors
76+
; NO-VP-NEXT: }
77+
78+
79+
entry:
80+
%cmp30 = icmp sgt i64 %N, 0
81+
br i1 %cmp30, label %for.body, label %for.cond.cleanup
82+
83+
for.cond.cleanup:
84+
ret void
85+
86+
for.body:
87+
%indvars.iv = phi i64 [ %indvars.iv.next, %for.body ], [ 0, %entry ]
88+
%arrayidx = getelementptr inbounds i32, ptr %b, i64 %indvars.iv
89+
%0 = load i32, ptr %arrayidx, align 4
90+
%arrayidx3 = getelementptr inbounds i32, ptr %c, i64 %indvars.iv
91+
%1 = load i32, ptr %arrayidx3, align 4
92+
%cmp4 = icmp sgt i32 %0, %1
93+
%2 = sub i32 0, %1
94+
%cond.p = select i1 %cmp4, i32 %1, i32 %2
95+
%cond = add i32 %cond.p, %0
96+
%arrayidx15 = getelementptr inbounds i32, ptr %a, i64 %indvars.iv
97+
store i32 %cond, ptr %arrayidx15, align 4
98+
%indvars.iv.next = add nuw nsw i64 %indvars.iv, 1
99+
%exitcond.not = icmp eq i64 %indvars.iv.next, %N
100+
br i1 %exitcond.not, label %for.cond.cleanup, label %for.body
101+
}

0 commit comments

Comments
 (0)