1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv32 -mattr=+v -verify-machineinstrs < %s | FileCheck %s
3 ; RUN: llc -mtriple=riscv64 -mattr=+v -verify-machineinstrs < %s | FileCheck %s
5 define <4 x i64> @m2_splat_0(<4 x i64> %v1) vscale_range(2,2) {
6 ; CHECK-LABEL: m2_splat_0:
8 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, ma
9 ; CHECK-NEXT: vrgather.vi v10, v8, 0
10 ; CHECK-NEXT: vmv.v.v v8, v10
12 %res = shufflevector <4 x i64> %v1, <4 x i64> poison, <4 x i32> <i32 0, i32 0, i32 0, i32 0>
16 define <4 x i64> @m2_splat_in_chunks(<4 x i64> %v1) vscale_range(2,2) {
17 ; CHECK-LABEL: m2_splat_in_chunks:
19 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
20 ; CHECK-NEXT: vrgather.vi v10, v8, 0
21 ; CHECK-NEXT: vrgather.vi v11, v9, 0
22 ; CHECK-NEXT: vmv2r.v v8, v10
24 %res = shufflevector <4 x i64> %v1, <4 x i64> poison, <4 x i32> <i32 0, i32 0, i32 2, i32 2>
28 define <8 x i64> @m4_splat_in_chunks(<8 x i64> %v1) vscale_range(2,2) {
29 ; CHECK-LABEL: m4_splat_in_chunks:
31 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
32 ; CHECK-NEXT: vrgather.vi v12, v8, 0
33 ; CHECK-NEXT: vrgather.vi v13, v9, 0
34 ; CHECK-NEXT: vrgather.vi v14, v10, 0
35 ; CHECK-NEXT: vrgather.vi v15, v11, 1
36 ; CHECK-NEXT: vmv4r.v v8, v12
38 %res = shufflevector <8 x i64> %v1, <8 x i64> poison, <8 x i32> <i32 0, i32 0, i32 2, i32 2, i32 4, i32 4, i32 7, i32 7>
43 define <4 x i64> @m2_splat_with_tail(<4 x i64> %v1) vscale_range(2,2) {
44 ; CHECK-LABEL: m2_splat_with_tail:
46 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
47 ; CHECK-NEXT: vrgather.vi v10, v8, 0
48 ; CHECK-NEXT: vmv1r.v v11, v9
49 ; CHECK-NEXT: vmv2r.v v8, v10
51 %res = shufflevector <4 x i64> %v1, <4 x i64> poison, <4 x i32> <i32 0, i32 0, i32 2, i32 3>
55 define <4 x i64> @m2_pair_swap_vl4(<4 x i64> %v1) vscale_range(2,2) {
56 ; CHECK-LABEL: m2_pair_swap_vl4:
58 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
59 ; CHECK-NEXT: vslidedown.vi v11, v9, 1
60 ; CHECK-NEXT: vslideup.vi v11, v9, 1
61 ; CHECK-NEXT: vslidedown.vi v10, v8, 1
62 ; CHECK-NEXT: vslideup.vi v10, v8, 1
63 ; CHECK-NEXT: vmv2r.v v8, v10
65 %res = shufflevector <4 x i64> %v1, <4 x i64> poison, <4 x i32> <i32 1, i32 0, i32 3, i32 2>
69 define <8 x i32> @m2_pair_swap_vl8(<8 x i32> %v1) vscale_range(2,2) {
70 ; RV32-LABEL: m2_pair_swap_vl8:
72 ; RV32-NEXT: li a0, 32
73 ; RV32-NEXT: vsetivli zero, 4, e64, m2, ta, ma
74 ; RV32-NEXT: vmv.v.x v10, a0
75 ; RV32-NEXT: li a0, 63
76 ; RV32-NEXT: vand.vx v12, v10, a0
77 ; RV32-NEXT: vsll.vv v12, v8, v12
78 ; RV32-NEXT: vrsub.vi v10, v10, 0
79 ; RV32-NEXT: vand.vx v10, v10, a0
80 ; RV32-NEXT: vsrl.vv v8, v8, v10
81 ; RV32-NEXT: vor.vv v8, v12, v8
84 ; RV64-LABEL: m2_pair_swap_vl8:
86 ; RV64-NEXT: li a0, 32
87 ; RV64-NEXT: vsetivli zero, 4, e64, m2, ta, ma
88 ; RV64-NEXT: vsrl.vx v10, v8, a0
89 ; RV64-NEXT: vsll.vx v8, v8, a0
90 ; RV64-NEXT: vor.vv v8, v8, v10
92 %res = shufflevector <8 x i32> %v1, <8 x i32> poison, <8 x i32> <i32 1, i32 0, i32 3, i32 2, i32 5, i32 4, i32 7, i32 6>
96 define <4 x i64> @m2_splat_into_identity(<4 x i64> %v1) vscale_range(2,2) {
97 ; CHECK-LABEL: m2_splat_into_identity:
99 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
100 ; CHECK-NEXT: vrgather.vi v10, v8, 0
101 ; CHECK-NEXT: vmv1r.v v11, v9
102 ; CHECK-NEXT: vmv2r.v v8, v10
104 %res = shufflevector <4 x i64> %v1, <4 x i64> poison, <4 x i32> <i32 0, i32 0, i32 2, i32 3>
108 define <4 x i64> @m2_broadcast_i128(<4 x i64> %v1) vscale_range(2,2) {
109 ; CHECK-LABEL: m2_broadcast_i128:
111 ; CHECK-NEXT: vmv1r.v v9, v8
113 %res = shufflevector <4 x i64> %v1, <4 x i64> poison, <4 x i32> <i32 0, i32 1, i32 0, i32 1>
117 define <8 x i64> @m4_broadcast_i128(<8 x i64> %v1) vscale_range(2,2) {
118 ; CHECK-LABEL: m4_broadcast_i128:
120 ; CHECK-NEXT: vmv1r.v v9, v8
121 ; CHECK-NEXT: vmv1r.v v10, v8
122 ; CHECK-NEXT: vmv1r.v v11, v8
124 %res = shufflevector <8 x i64> %v1, <8 x i64> poison, <8 x i32> <i32 0, i32 1, i32 0, i32 1, i32 0, i32 1, i32 0, i32 1>
129 define <4 x i64> @m2_splat_two_source(<4 x i64> %v1, <4 x i64> %v2) vscale_range(2,2) {
130 ; CHECK-LABEL: m2_splat_two_source:
132 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
133 ; CHECK-NEXT: vrgather.vi v12, v8, 0
134 ; CHECK-NEXT: vrgather.vi v13, v11, 1
135 ; CHECK-NEXT: vmv2r.v v8, v12
137 %res = shufflevector <4 x i64> %v1, <4 x i64> %v2, <4 x i32> <i32 0, i32 0, i32 7, i32 7>
141 define <4 x i64> @m2_splat_into_identity_two_source_v2_hi(<4 x i64> %v1, <4 x i64> %v2) vscale_range(2,2) {
142 ; CHECK-LABEL: m2_splat_into_identity_two_source_v2_hi:
144 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
145 ; CHECK-NEXT: vrgather.vi v10, v8, 0
146 ; CHECK-NEXT: vmv2r.v v8, v10
148 %res = shufflevector <4 x i64> %v1, <4 x i64> %v2, <4 x i32> <i32 0, i32 0, i32 6, i32 7>
152 define <4 x i64> @m2_splat_into_slide_two_source_v2_lo(<4 x i64> %v1, <4 x i64> %v2) vscale_range(2,2) {
153 ; CHECK-LABEL: m2_splat_into_slide_two_source_v2_lo:
155 ; CHECK-NEXT: vsetivli zero, 2, e64, m1, ta, ma
156 ; CHECK-NEXT: vrgather.vi v12, v8, 0
157 ; CHECK-NEXT: vmv1r.v v13, v10
158 ; CHECK-NEXT: vmv2r.v v8, v12
160 %res = shufflevector <4 x i64> %v1, <4 x i64> %v2, <4 x i32> <i32 0, i32 0, i32 4, i32 5>
164 define <4 x i64> @m2_splat_into_slide_two_source(<4 x i64> %v1, <4 x i64> %v2) vscale_range(2,2) {
165 ; CHECK-LABEL: m2_splat_into_slide_two_source:
167 ; CHECK-NEXT: vsetivli zero, 1, e8, mf8, ta, ma
168 ; CHECK-NEXT: vmv.v.i v0, 12
169 ; CHECK-NEXT: vsetivli zero, 4, e64, m2, ta, mu
170 ; CHECK-NEXT: vrgather.vi v12, v8, 0
171 ; CHECK-NEXT: vslideup.vi v12, v10, 1, v0.t
172 ; CHECK-NEXT: vmv.v.v v8, v12
174 %res = shufflevector <4 x i64> %v1, <4 x i64> %v2, <4 x i32> <i32 0, i32 0, i32 5, i32 6>