1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=riscv64 -mattr=+m,+f,+d,+v -verify-machineinstrs < %s | FileCheck %s
4 define <vscale x 1 x double> @test_vp_reverse_nxv1f64_masked(<vscale x 1 x double> %src, <vscale x 1 x i1> %mask, i32 zeroext %evl) {
5 ; CHECK-LABEL: test_vp_reverse_nxv1f64_masked:
7 ; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma
8 ; CHECK-NEXT: vid.v v9, v0.t
9 ; CHECK-NEXT: addi a0, a0, -1
10 ; CHECK-NEXT: vrsub.vx v10, v9, a0, v0.t
11 ; CHECK-NEXT: vrgather.vv v9, v8, v10, v0.t
12 ; CHECK-NEXT: vmv.v.v v8, v9
14 %dst = call <vscale x 1 x double> @llvm.experimental.vp.reverse.nxv1f64(<vscale x 1 x double> %src, <vscale x 1 x i1> %mask, i32 %evl)
15 ret <vscale x 1 x double> %dst
18 define <vscale x 1 x double> @test_vp_reverse_nxv1f64(<vscale x 1 x double> %src, i32 zeroext %evl) {
19 ; CHECK-LABEL: test_vp_reverse_nxv1f64:
21 ; CHECK-NEXT: addi a1, a0, -1
22 ; CHECK-NEXT: vsetvli zero, a0, e64, m1, ta, ma
23 ; CHECK-NEXT: vid.v v9
24 ; CHECK-NEXT: vrsub.vx v10, v9, a1
25 ; CHECK-NEXT: vrgather.vv v9, v8, v10
26 ; CHECK-NEXT: vmv.v.v v8, v9
28 %head = insertelement <vscale x 1 x i1> undef, i1 1, i32 0
29 %allones = shufflevector <vscale x 1 x i1> %head, <vscale x 1 x i1> undef, <vscale x 1 x i32> zeroinitializer
31 %dst = call <vscale x 1 x double> @llvm.experimental.vp.reverse.nxv1f64(<vscale x 1 x double> %src, <vscale x 1 x i1> %allones, i32 %evl)
32 ret <vscale x 1 x double> %dst
35 define <vscale x 2 x float> @test_vp_reverse_nxv2f32_masked(<vscale x 2 x float> %src, <vscale x 2 x i1> %mask, i32 zeroext %evl) {
36 ; CHECK-LABEL: test_vp_reverse_nxv2f32_masked:
38 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
39 ; CHECK-NEXT: vid.v v9, v0.t
40 ; CHECK-NEXT: addi a0, a0, -1
41 ; CHECK-NEXT: vrsub.vx v10, v9, a0, v0.t
42 ; CHECK-NEXT: vrgather.vv v9, v8, v10, v0.t
43 ; CHECK-NEXT: vmv.v.v v8, v9
45 %dst = call <vscale x 2 x float> @llvm.experimental.vp.reverse.nxv2f32(<vscale x 2 x float> %src, <vscale x 2 x i1> %mask, i32 %evl)
46 ret <vscale x 2 x float> %dst
49 define <vscale x 2 x float> @test_vp_reverse_nxv2f32(<vscale x 2 x float> %src, i32 zeroext %evl) {
50 ; CHECK-LABEL: test_vp_reverse_nxv2f32:
52 ; CHECK-NEXT: addi a1, a0, -1
53 ; CHECK-NEXT: vsetvli zero, a0, e32, m1, ta, ma
54 ; CHECK-NEXT: vid.v v9
55 ; CHECK-NEXT: vrsub.vx v10, v9, a1
56 ; CHECK-NEXT: vrgather.vv v9, v8, v10
57 ; CHECK-NEXT: vmv.v.v v8, v9
59 %head = insertelement <vscale x 2 x i1> undef, i1 1, i32 0
60 %allones = shufflevector <vscale x 2 x i1> %head, <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer
62 %dst = call <vscale x 2 x float> @llvm.experimental.vp.reverse.nxv2f32(<vscale x 2 x float> %src, <vscale x 2 x i1> %allones, i32 %evl)
63 ret <vscale x 2 x float> %dst
66 define <vscale x 2 x double> @test_vp_reverse_nxv2f64_masked(<vscale x 2 x double> %src, <vscale x 2 x i1> %mask, i32 zeroext %evl) {
67 ; CHECK-LABEL: test_vp_reverse_nxv2f64_masked:
69 ; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma
70 ; CHECK-NEXT: vid.v v10, v0.t
71 ; CHECK-NEXT: addi a0, a0, -1
72 ; CHECK-NEXT: vrsub.vx v12, v10, a0, v0.t
73 ; CHECK-NEXT: vrgather.vv v10, v8, v12, v0.t
74 ; CHECK-NEXT: vmv.v.v v8, v10
76 %dst = call <vscale x 2 x double> @llvm.experimental.vp.reverse.nxv2f64(<vscale x 2 x double> %src, <vscale x 2 x i1> %mask, i32 %evl)
77 ret <vscale x 2 x double> %dst
80 define <vscale x 2 x double> @test_vp_reverse_nxv2f64(<vscale x 2 x double> %src, i32 zeroext %evl) {
81 ; CHECK-LABEL: test_vp_reverse_nxv2f64:
83 ; CHECK-NEXT: addi a1, a0, -1
84 ; CHECK-NEXT: vsetvli zero, a0, e64, m2, ta, ma
85 ; CHECK-NEXT: vid.v v10
86 ; CHECK-NEXT: vrsub.vx v12, v10, a1
87 ; CHECK-NEXT: vrgather.vv v10, v8, v12
88 ; CHECK-NEXT: vmv.v.v v8, v10
90 %head = insertelement <vscale x 2 x i1> undef, i1 1, i32 0
91 %allones = shufflevector <vscale x 2 x i1> %head, <vscale x 2 x i1> undef, <vscale x 2 x i32> zeroinitializer
93 %dst = call <vscale x 2 x double> @llvm.experimental.vp.reverse.nxv2f64(<vscale x 2 x double> %src, <vscale x 2 x i1> %allones, i32 %evl)
94 ret <vscale x 2 x double> %dst
97 define <vscale x 4 x float> @test_vp_reverse_nxv4f32_masked(<vscale x 4 x float> %src, <vscale x 4 x i1> %mask, i32 zeroext %evl) {
98 ; CHECK-LABEL: test_vp_reverse_nxv4f32_masked:
100 ; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma
101 ; CHECK-NEXT: vid.v v10, v0.t
102 ; CHECK-NEXT: addi a0, a0, -1
103 ; CHECK-NEXT: vrsub.vx v12, v10, a0, v0.t
104 ; CHECK-NEXT: vrgather.vv v10, v8, v12, v0.t
105 ; CHECK-NEXT: vmv.v.v v8, v10
107 %dst = call <vscale x 4 x float> @llvm.experimental.vp.reverse.nxv4f32(<vscale x 4 x float> %src, <vscale x 4 x i1> %mask, i32 %evl)
108 ret <vscale x 4 x float> %dst
111 define <vscale x 4 x float> @test_vp_reverse_nxv4f32(<vscale x 4 x float> %src, i32 zeroext %evl) {
112 ; CHECK-LABEL: test_vp_reverse_nxv4f32:
114 ; CHECK-NEXT: addi a1, a0, -1
115 ; CHECK-NEXT: vsetvli zero, a0, e32, m2, ta, ma
116 ; CHECK-NEXT: vid.v v10
117 ; CHECK-NEXT: vrsub.vx v12, v10, a1
118 ; CHECK-NEXT: vrgather.vv v10, v8, v12
119 ; CHECK-NEXT: vmv.v.v v8, v10
121 %head = insertelement <vscale x 4 x i1> undef, i1 1, i32 0
122 %allones = shufflevector <vscale x 4 x i1> %head, <vscale x 4 x i1> undef, <vscale x 4 x i32> zeroinitializer
124 %dst = call <vscale x 4 x float> @llvm.experimental.vp.reverse.nxv4f32(<vscale x 4 x float> %src, <vscale x 4 x i1> %allones, i32 %evl)
125 ret <vscale x 4 x float> %dst
128 define <vscale x 4 x double> @test_vp_reverse_nxv4f64_masked(<vscale x 4 x double> %src, <vscale x 4 x i1> %mask, i32 zeroext %evl) {
129 ; CHECK-LABEL: test_vp_reverse_nxv4f64_masked:
131 ; CHECK-NEXT: vsetvli zero, a0, e64, m4, ta, ma
132 ; CHECK-NEXT: vid.v v12, v0.t
133 ; CHECK-NEXT: addi a0, a0, -1
134 ; CHECK-NEXT: vrsub.vx v16, v12, a0, v0.t
135 ; CHECK-NEXT: vrgather.vv v12, v8, v16, v0.t
136 ; CHECK-NEXT: vmv.v.v v8, v12
138 %dst = call <vscale x 4 x double> @llvm.experimental.vp.reverse.nxv4f64(<vscale x 4 x double> %src, <vscale x 4 x i1> %mask, i32 %evl)
139 ret <vscale x 4 x double> %dst
142 define <vscale x 4 x double> @test_vp_reverse_nxv4f64(<vscale x 4 x double> %src, i32 zeroext %evl) {
143 ; CHECK-LABEL: test_vp_reverse_nxv4f64:
145 ; CHECK-NEXT: addi a1, a0, -1
146 ; CHECK-NEXT: vsetvli zero, a0, e64, m4, ta, ma
147 ; CHECK-NEXT: vid.v v12
148 ; CHECK-NEXT: vrsub.vx v16, v12, a1
149 ; CHECK-NEXT: vrgather.vv v12, v8, v16
150 ; CHECK-NEXT: vmv.v.v v8, v12
152 %head = insertelement <vscale x 4 x i1> undef, i1 1, i32 0
153 %allones = shufflevector <vscale x 4 x i1> %head, <vscale x 4 x i1> undef, <vscale x 4 x i32> zeroinitializer
155 %dst = call <vscale x 4 x double> @llvm.experimental.vp.reverse.nxv4f64(<vscale x 4 x double> %src, <vscale x 4 x i1> %allones, i32 %evl)
156 ret <vscale x 4 x double> %dst
159 define <vscale x 8 x float> @test_vp_reverse_nxv8f32_masked(<vscale x 8 x float> %src, <vscale x 8 x i1> %mask, i32 zeroext %evl) {
160 ; CHECK-LABEL: test_vp_reverse_nxv8f32_masked:
162 ; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma
163 ; CHECK-NEXT: vid.v v12, v0.t
164 ; CHECK-NEXT: addi a0, a0, -1
165 ; CHECK-NEXT: vrsub.vx v16, v12, a0, v0.t
166 ; CHECK-NEXT: vrgather.vv v12, v8, v16, v0.t
167 ; CHECK-NEXT: vmv.v.v v8, v12
169 %dst = call <vscale x 8 x float> @llvm.experimental.vp.reverse.nxv8f32(<vscale x 8 x float> %src, <vscale x 8 x i1> %mask, i32 %evl)
170 ret <vscale x 8 x float> %dst
173 define <vscale x 8 x float> @test_vp_reverse_nxv8f32(<vscale x 8 x float> %src, i32 zeroext %evl) {
174 ; CHECK-LABEL: test_vp_reverse_nxv8f32:
176 ; CHECK-NEXT: addi a1, a0, -1
177 ; CHECK-NEXT: vsetvli zero, a0, e32, m4, ta, ma
178 ; CHECK-NEXT: vid.v v12
179 ; CHECK-NEXT: vrsub.vx v16, v12, a1
180 ; CHECK-NEXT: vrgather.vv v12, v8, v16
181 ; CHECK-NEXT: vmv.v.v v8, v12
183 %head = insertelement <vscale x 8 x i1> undef, i1 1, i32 0
184 %allones = shufflevector <vscale x 8 x i1> %head, <vscale x 8 x i1> undef, <vscale x 8 x i32> zeroinitializer
186 %dst = call <vscale x 8 x float> @llvm.experimental.vp.reverse.nxv8f32(<vscale x 8 x float> %src, <vscale x 8 x i1> %allones, i32 %evl)
187 ret <vscale x 8 x float> %dst
190 define <vscale x 8 x double> @test_vp_reverse_nxv8f64_masked(<vscale x 8 x double> %src, <vscale x 8 x i1> %mask, i32 zeroext %evl) {
191 ; CHECK-LABEL: test_vp_reverse_nxv8f64_masked:
193 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
194 ; CHECK-NEXT: vid.v v16, v0.t
195 ; CHECK-NEXT: addi a0, a0, -1
196 ; CHECK-NEXT: vrsub.vx v24, v16, a0, v0.t
197 ; CHECK-NEXT: vrgather.vv v16, v8, v24, v0.t
198 ; CHECK-NEXT: vmv.v.v v8, v16
200 %dst = call <vscale x 8 x double> @llvm.experimental.vp.reverse.nxv8f64(<vscale x 8 x double> %src, <vscale x 8 x i1> %mask, i32 %evl)
201 ret <vscale x 8 x double> %dst
204 define <vscale x 8 x double> @test_vp_reverse_nxv8f64(<vscale x 8 x double> %src, i32 zeroext %evl) {
205 ; CHECK-LABEL: test_vp_reverse_nxv8f64:
207 ; CHECK-NEXT: addi a1, a0, -1
208 ; CHECK-NEXT: vsetvli zero, a0, e64, m8, ta, ma
209 ; CHECK-NEXT: vid.v v16
210 ; CHECK-NEXT: vrsub.vx v24, v16, a1
211 ; CHECK-NEXT: vrgather.vv v16, v8, v24
212 ; CHECK-NEXT: vmv.v.v v8, v16
214 %head = insertelement <vscale x 8 x i1> undef, i1 1, i32 0
215 %allones = shufflevector <vscale x 8 x i1> %head, <vscale x 8 x i1> undef, <vscale x 8 x i32> zeroinitializer
217 %dst = call <vscale x 8 x double> @llvm.experimental.vp.reverse.nxv8f64(<vscale x 8 x double> %src, <vscale x 8 x i1> %allones, i32 %evl)
218 ret <vscale x 8 x double> %dst
221 define <vscale x 16 x float> @test_vp_reverse_nxv16f32_masked(<vscale x 16 x float> %src, <vscale x 16 x i1> %mask, i32 zeroext %evl) {
222 ; CHECK-LABEL: test_vp_reverse_nxv16f32_masked:
224 ; CHECK-NEXT: vsetvli zero, a0, e32, m8, ta, ma
225 ; CHECK-NEXT: vid.v v16, v0.t
226 ; CHECK-NEXT: addi a0, a0, -1
227 ; CHECK-NEXT: vrsub.vx v24, v16, a0, v0.t
228 ; CHECK-NEXT: vrgather.vv v16, v8, v24, v0.t
229 ; CHECK-NEXT: vmv.v.v v8, v16
231 %dst = call <vscale x 16 x float> @llvm.experimental.vp.reverse.nxv16f32(<vscale x 16 x float> %src, <vscale x 16 x i1> %mask, i32 %evl)
232 ret <vscale x 16 x float> %dst
235 define <vscale x 16 x float> @test_vp_reverse_nxv16f32(<vscale x 16 x float> %src, i32 zeroext %evl) {
236 ; CHECK-LABEL: test_vp_reverse_nxv16f32:
238 ; CHECK-NEXT: addi a1, a0, -1
239 ; CHECK-NEXT: vsetvli zero, a0, e32, m8, ta, ma
240 ; CHECK-NEXT: vid.v v16
241 ; CHECK-NEXT: vrsub.vx v24, v16, a1
242 ; CHECK-NEXT: vrgather.vv v16, v8, v24
243 ; CHECK-NEXT: vmv.v.v v8, v16
245 %head = insertelement <vscale x 16 x i1> undef, i1 1, i32 0
246 %allones = shufflevector <vscale x 16 x i1> %head, <vscale x 16 x i1> undef, <vscale x 16 x i32> zeroinitializer
248 %dst = call <vscale x 16 x float> @llvm.experimental.vp.reverse.nxv16f32(<vscale x 16 x float> %src, <vscale x 16 x i1> %allones, i32 %evl)
249 ret <vscale x 16 x float> %dst
253 declare <vscale x 1 x double> @llvm.experimental.vp.reverse.nxv1f64(<vscale x 1 x double>,<vscale x 1 x i1>,i32)
254 declare <vscale x 2 x float> @llvm.experimental.vp.reverse.nxv2f32(<vscale x 2 x float>,<vscale x 2 x i1>,i32)
257 declare <vscale x 2 x double> @llvm.experimental.vp.reverse.nxv2f64(<vscale x 2 x double>,<vscale x 2 x i1>,i32)
258 declare <vscale x 4 x float> @llvm.experimental.vp.reverse.nxv4f32(<vscale x 4 x float>,<vscale x 4 x i1>,i32)
261 declare <vscale x 4 x double> @llvm.experimental.vp.reverse.nxv4f64(<vscale x 4 x double>,<vscale x 4 x i1>,i32)
262 declare <vscale x 8 x float> @llvm.experimental.vp.reverse.nxv8f32(<vscale x 8 x float>,<vscale x 8 x i1>,i32)
265 declare <vscale x 8 x double> @llvm.experimental.vp.reverse.nxv8f64(<vscale x 8 x double>,<vscale x 8 x i1>,i32)
266 declare <vscale x 16 x float> @llvm.experimental.vp.reverse.nxv16f32(<vscale x 16 x float>,<vscale x 16 x i1>,i32)