1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mattr=+sve -mtriple=aarch64 %s -o - | FileCheck %s --check-prefixes=CHECK
4 ; These tests just check that the plumbing is in place for @llvm.smax, @llvm.umax,
5 ; @llvm.smin, @llvm.umin.
9 define <vscale x 16 x i8> @smax_select_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
10 ; CHECK-LABEL: smax_select_i8:
12 ; CHECK-NEXT: smax z0.b, p0/m, z0.b, z1.b
14 %sel = call <vscale x 16 x i8> @llvm.smax.nxv16i8(<vscale x 16 x i8> %a, <vscale x 16 x i8> %b)
15 %out = select <vscale x 16 x i1> %pg, <vscale x 16 x i8> %sel, <vscale x 16 x i8> %a
16 ret <vscale x 16 x i8> %out
19 define <vscale x 8 x i16> @smax_select_i16(<vscale x 8 x i1> %pg, <vscale x 8 x i16> %a, <vscale x 8 x i16> %b) {
20 ; CHECK-LABEL: smax_select_i16:
22 ; CHECK-NEXT: smax z0.h, p0/m, z0.h, z1.h
24 %sel = call <vscale x 8 x i16> @llvm.smax.nxv8i16(<vscale x 8 x i16> %a, <vscale x 8 x i16> %b)
25 %out = select <vscale x 8 x i1> %pg, <vscale x 8 x i16> %sel, <vscale x 8 x i16> %a
26 ret <vscale x 8 x i16> %out
29 define <vscale x 4 x i32> @smax_select_i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
30 ; CHECK-LABEL: smax_select_i32:
32 ; CHECK-NEXT: smax z0.s, p0/m, z0.s, z1.s
34 %sel = call <vscale x 4 x i32> @llvm.smax.nxv4i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
35 %out = select <vscale x 4 x i1> %pg, <vscale x 4 x i32> %sel, <vscale x 4 x i32> %a
36 ret <vscale x 4 x i32> %out
39 define <vscale x 2 x i64> @smax_select_i64(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b) {
40 ; CHECK-LABEL: smax_select_i64:
42 ; CHECK-NEXT: smax z0.d, p0/m, z0.d, z1.d
44 %sel = call <vscale x 2 x i64> @llvm.smax.nxv2i64(<vscale x 2 x i64> %a, <vscale x 2 x i64> %b)
45 %out = select <vscale x 2 x i1> %pg, <vscale x 2 x i64> %sel, <vscale x 2 x i64> %a
46 ret <vscale x 2 x i64> %out
51 define <vscale x 16 x i8> @umax_select_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
52 ; CHECK-LABEL: umax_select_i8:
54 ; CHECK-NEXT: umax z0.b, p0/m, z0.b, z1.b
56 %sel = call <vscale x 16 x i8> @llvm.umax.nxv16i8(<vscale x 16 x i8> %a, <vscale x 16 x i8> %b)
57 %out = select <vscale x 16 x i1> %pg, <vscale x 16 x i8> %sel, <vscale x 16 x i8> %a
58 ret <vscale x 16 x i8> %out
61 define <vscale x 8 x i16> @umax_select_i16(<vscale x 8 x i1> %pg, <vscale x 8 x i16> %a, <vscale x 8 x i16> %b) {
62 ; CHECK-LABEL: umax_select_i16:
64 ; CHECK-NEXT: umax z0.h, p0/m, z0.h, z1.h
66 %sel = call <vscale x 8 x i16> @llvm.umax.nxv8i16(<vscale x 8 x i16> %a, <vscale x 8 x i16> %b)
67 %out = select <vscale x 8 x i1> %pg, <vscale x 8 x i16> %sel, <vscale x 8 x i16> %a
68 ret <vscale x 8 x i16> %out
71 define <vscale x 4 x i32> @umax_select_i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
72 ; CHECK-LABEL: umax_select_i32:
74 ; CHECK-NEXT: umax z0.s, p0/m, z0.s, z1.s
76 %sel = call <vscale x 4 x i32> @llvm.umax.nxv4i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
77 %out = select <vscale x 4 x i1> %pg, <vscale x 4 x i32> %sel, <vscale x 4 x i32> %a
78 ret <vscale x 4 x i32> %out
81 define <vscale x 2 x i64> @umax_select_i64(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b) {
82 ; CHECK-LABEL: umax_select_i64:
84 ; CHECK-NEXT: umax z0.d, p0/m, z0.d, z1.d
86 %sel = call <vscale x 2 x i64> @llvm.umax.nxv2i64(<vscale x 2 x i64> %a, <vscale x 2 x i64> %b)
87 %out = select <vscale x 2 x i1> %pg, <vscale x 2 x i64> %sel, <vscale x 2 x i64> %a
88 ret <vscale x 2 x i64> %out
93 define <vscale x 16 x i8> @smin_select_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
94 ; CHECK-LABEL: smin_select_i8:
96 ; CHECK-NEXT: smin z0.b, p0/m, z0.b, z1.b
98 %sel = call <vscale x 16 x i8> @llvm.smin.nxv16i8(<vscale x 16 x i8> %a, <vscale x 16 x i8> %b)
99 %out = select <vscale x 16 x i1> %pg, <vscale x 16 x i8> %sel, <vscale x 16 x i8> %a
100 ret <vscale x 16 x i8> %out
103 define <vscale x 8 x i16> @smin_select_i16(<vscale x 8 x i1> %pg, <vscale x 8 x i16> %a, <vscale x 8 x i16> %b) {
104 ; CHECK-LABEL: smin_select_i16:
106 ; CHECK-NEXT: smin z0.h, p0/m, z0.h, z1.h
108 %sel = call <vscale x 8 x i16> @llvm.smin.nxv8i16(<vscale x 8 x i16> %a, <vscale x 8 x i16> %b)
109 %out = select <vscale x 8 x i1> %pg, <vscale x 8 x i16> %sel, <vscale x 8 x i16> %a
110 ret <vscale x 8 x i16> %out
113 define <vscale x 4 x i32> @smin_select_i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
114 ; CHECK-LABEL: smin_select_i32:
116 ; CHECK-NEXT: smin z0.s, p0/m, z0.s, z1.s
118 %sel = call <vscale x 4 x i32> @llvm.smin.nxv4i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
119 %out = select <vscale x 4 x i1> %pg, <vscale x 4 x i32> %sel, <vscale x 4 x i32> %a
120 ret <vscale x 4 x i32> %out
123 define <vscale x 2 x i64> @smin_select_i64(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b) {
124 ; CHECK-LABEL: smin_select_i64:
126 ; CHECK-NEXT: smin z0.d, p0/m, z0.d, z1.d
128 %sel = call <vscale x 2 x i64> @llvm.smin.nxv2i64(<vscale x 2 x i64> %a, <vscale x 2 x i64> %b)
129 %out = select <vscale x 2 x i1> %pg, <vscale x 2 x i64> %sel, <vscale x 2 x i64> %a
130 ret <vscale x 2 x i64> %out
135 define <vscale x 16 x i8> @umin_select_i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %a, <vscale x 16 x i8> %b) {
136 ; CHECK-LABEL: umin_select_i8:
138 ; CHECK-NEXT: umin z0.b, p0/m, z0.b, z1.b
140 %sel = call <vscale x 16 x i8> @llvm.umin.nxv16i8(<vscale x 16 x i8> %a, <vscale x 16 x i8> %b)
141 %out = select <vscale x 16 x i1> %pg, <vscale x 16 x i8> %sel, <vscale x 16 x i8> %a
142 ret <vscale x 16 x i8> %out
145 define <vscale x 8 x i16> @umin_select_i16(<vscale x 8 x i1> %pg, <vscale x 8 x i16> %a, <vscale x 8 x i16> %b) {
146 ; CHECK-LABEL: umin_select_i16:
148 ; CHECK-NEXT: umin z0.h, p0/m, z0.h, z1.h
150 %sel = call <vscale x 8 x i16> @llvm.umin.nxv8i16(<vscale x 8 x i16> %a, <vscale x 8 x i16> %b)
151 %out = select <vscale x 8 x i1> %pg, <vscale x 8 x i16> %sel, <vscale x 8 x i16> %a
152 ret <vscale x 8 x i16> %out
155 define <vscale x 4 x i32> @umin_select_i32(<vscale x 4 x i1> %pg, <vscale x 4 x i32> %a, <vscale x 4 x i32> %b) {
156 ; CHECK-LABEL: umin_select_i32:
158 ; CHECK-NEXT: umin z0.s, p0/m, z0.s, z1.s
160 %sel = call <vscale x 4 x i32> @llvm.umin.nxv4i32(<vscale x 4 x i32> %a, <vscale x 4 x i32> %b)
161 %out = select <vscale x 4 x i1> %pg, <vscale x 4 x i32> %sel, <vscale x 4 x i32> %a
162 ret <vscale x 4 x i32> %out
165 define <vscale x 2 x i64> @umin_select_i64(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b) {
166 ; CHECK-LABEL: umin_select_i64:
168 ; CHECK-NEXT: umin z0.d, p0/m, z0.d, z1.d
170 %sel = call <vscale x 2 x i64> @llvm.umin.nxv2i64(<vscale x 2 x i64> %a, <vscale x 2 x i64> %b)
171 %out = select <vscale x 2 x i1> %pg, <vscale x 2 x i64> %sel, <vscale x 2 x i64> %a
172 ret <vscale x 2 x i64> %out
176 define <vscale x 2 x i64> @umin_select_i64_multiuse(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b, ptr %p) {
177 ; CHECK-LABEL: umin_select_i64_multiuse:
179 ; CHECK-NEXT: ptrue p1.d
180 ; CHECK-NEXT: umin z1.d, p1/m, z1.d, z0.d
181 ; CHECK-NEXT: mov z0.d, p0/m, z1.d
182 ; CHECK-NEXT: st1d { z1.d }, p1, [x0]
184 %sel = call <vscale x 2 x i64> @llvm.umin.nxv2i64(<vscale x 2 x i64> %a, <vscale x 2 x i64> %b)
185 store <vscale x 2 x i64> %sel, ptr %p
186 %out = select <vscale x 2 x i1> %pg, <vscale x 2 x i64> %sel, <vscale x 2 x i64> %a
187 ret <vscale x 2 x i64> %out
190 define <vscale x 2 x i64> @smin_select_i64_c(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b) {
191 ; CHECK-LABEL: smin_select_i64_c:
193 ; CHECK-NEXT: smin z1.d, p0/m, z1.d, z0.d
194 ; CHECK-NEXT: mov z0.d, z1.d
196 %sel = call <vscale x 2 x i64> @llvm.smin.nxv2i64(<vscale x 2 x i64> %a, <vscale x 2 x i64> %b)
197 %out = select <vscale x 2 x i1> %pg, <vscale x 2 x i64> %sel, <vscale x 2 x i64> %b
198 ret <vscale x 2 x i64> %out
201 define <vscale x 2 x i64> @smax_select_i64_c(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b) {
202 ; CHECK-LABEL: smax_select_i64_c:
204 ; CHECK-NEXT: smax z1.d, p0/m, z1.d, z0.d
205 ; CHECK-NEXT: mov z0.d, z1.d
207 %sel = call <vscale x 2 x i64> @llvm.smax.nxv2i64(<vscale x 2 x i64> %a, <vscale x 2 x i64> %b)
208 %out = select <vscale x 2 x i1> %pg, <vscale x 2 x i64> %sel, <vscale x 2 x i64> %b
209 ret <vscale x 2 x i64> %out
212 define <vscale x 2 x i64> @umin_select_i64_c(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b) {
213 ; CHECK-LABEL: umin_select_i64_c:
215 ; CHECK-NEXT: umin z1.d, p0/m, z1.d, z0.d
216 ; CHECK-NEXT: mov z0.d, z1.d
218 %sel = call <vscale x 2 x i64> @llvm.umin.nxv2i64(<vscale x 2 x i64> %a, <vscale x 2 x i64> %b)
219 %out = select <vscale x 2 x i1> %pg, <vscale x 2 x i64> %sel, <vscale x 2 x i64> %b
220 ret <vscale x 2 x i64> %out
223 define <vscale x 2 x i64> @umax_select_i64_c(<vscale x 2 x i1> %pg, <vscale x 2 x i64> %a, <vscale x 2 x i64> %b) {
224 ; CHECK-LABEL: umax_select_i64_c:
226 ; CHECK-NEXT: umax z1.d, p0/m, z1.d, z0.d
227 ; CHECK-NEXT: mov z0.d, z1.d
229 %sel = call <vscale x 2 x i64> @llvm.umax.nxv2i64(<vscale x 2 x i64> %a, <vscale x 2 x i64> %b)
230 %out = select <vscale x 2 x i1> %pg, <vscale x 2 x i64> %sel, <vscale x 2 x i64> %b
231 ret <vscale x 2 x i64> %out
235 declare <vscale x 16 x i8> @llvm.smax.nxv16i8(<vscale x 16 x i8>, <vscale x 16 x i8>)
236 declare <vscale x 8 x i16> @llvm.smax.nxv8i16(<vscale x 8 x i16>, <vscale x 8 x i16>)
237 declare <vscale x 4 x i32> @llvm.smax.nxv4i32(<vscale x 4 x i32>, <vscale x 4 x i32>)
238 declare <vscale x 2 x i64> @llvm.smax.nxv2i64(<vscale x 2 x i64>, <vscale x 2 x i64>)
240 declare <vscale x 16 x i8> @llvm.umax.nxv16i8(<vscale x 16 x i8>, <vscale x 16 x i8>)
241 declare <vscale x 8 x i16> @llvm.umax.nxv8i16(<vscale x 8 x i16>, <vscale x 8 x i16>)
242 declare <vscale x 4 x i32> @llvm.umax.nxv4i32(<vscale x 4 x i32>, <vscale x 4 x i32>)
243 declare <vscale x 2 x i64> @llvm.umax.nxv2i64(<vscale x 2 x i64>, <vscale x 2 x i64>)
245 declare <vscale x 16 x i8> @llvm.smin.nxv16i8(<vscale x 16 x i8>, <vscale x 16 x i8>)
246 declare <vscale x 8 x i16> @llvm.smin.nxv8i16(<vscale x 8 x i16>, <vscale x 8 x i16>)
247 declare <vscale x 4 x i32> @llvm.smin.nxv4i32(<vscale x 4 x i32>, <vscale x 4 x i32>)
248 declare <vscale x 2 x i64> @llvm.smin.nxv2i64(<vscale x 2 x i64>, <vscale x 2 x i64>)
250 declare <vscale x 16 x i8> @llvm.umin.nxv16i8(<vscale x 16 x i8>, <vscale x 16 x i8>)
251 declare <vscale x 8 x i16> @llvm.umin.nxv8i16(<vscale x 8 x i16>, <vscale x 8 x i16>)
252 declare <vscale x 4 x i32> @llvm.umin.nxv4i32(<vscale x 4 x i32>, <vscale x 4 x i32>)
253 declare <vscale x 2 x i64> @llvm.umin.nxv2i64(<vscale x 2 x i64>, <vscale x 2 x i64>)