1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py UTC_ARGS: --version 2
2 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
3 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sme -force-streaming < %s | FileCheck %s
6 ; Converting to svbool_t (<vscale x 16 x i1>)
9 define <vscale x 16 x i1> @reinterpret_bool_from_b(<vscale x 16 x i1> %pg) {
10 ; CHECK-LABEL: reinterpret_bool_from_b:
13 %out = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv16i1(<vscale x 16 x i1> %pg)
14 ret <vscale x 16 x i1> %out
17 define <vscale x 16 x i1> @reinterpret_bool_from_h(<vscale x 8 x i1> %pg) {
18 ; CHECK-LABEL: reinterpret_bool_from_h:
20 ; CHECK-NEXT: ptrue p1.h
21 ; CHECK-NEXT: and p0.b, p0/z, p0.b, p1.b
23 %out = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv8i1(<vscale x 8 x i1> %pg)
24 ret <vscale x 16 x i1> %out
27 define <vscale x 16 x i1> @reinterpret_bool_from_s(<vscale x 4 x i1> %pg) {
28 ; CHECK-LABEL: reinterpret_bool_from_s:
30 ; CHECK-NEXT: ptrue p1.s
31 ; CHECK-NEXT: and p0.b, p0/z, p0.b, p1.b
33 %out = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv4i1(<vscale x 4 x i1> %pg)
34 ret <vscale x 16 x i1> %out
37 define <vscale x 16 x i1> @reinterpret_bool_from_d(<vscale x 2 x i1> %pg) {
38 ; CHECK-LABEL: reinterpret_bool_from_d:
40 ; CHECK-NEXT: ptrue p1.d
41 ; CHECK-NEXT: and p0.b, p0/z, p0.b, p1.b
43 %out = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv2i1(<vscale x 2 x i1> %pg)
44 ret <vscale x 16 x i1> %out
47 define <vscale x 16 x i1> @reinterpret_bool_from_q(<vscale x 1 x i1> %arg) {
48 ; CHECK-LABEL: reinterpret_bool_from_q:
50 ; CHECK-NEXT: ptrue p1.d
51 ; CHECK-NEXT: punpklo p1.h, p1.b
52 ; CHECK-NEXT: and p0.b, p0/z, p0.b, p1.b
54 %res = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv1i1(<vscale x 1 x i1> %arg)
55 ret <vscale x 16 x i1> %res
58 define <vscale x 16 x i1> @reinterpret_bool_from_svcount(target("aarch64.svcount") %pg) "target-features"="+sme2" {
59 ; CHECK-LABEL: reinterpret_bool_from_svcount:
62 %out = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.taarch64.svcountt(target("aarch64.svcount") %pg)
63 ret <vscale x 16 x i1> %out
67 ; Converting from svbool_t
70 define <vscale x 16 x i1> @reinterpret_bool_to_b(<vscale x 16 x i1> %pg) {
71 ; CHECK-LABEL: reinterpret_bool_to_b:
74 %out = call <vscale x 16 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv16i1(<vscale x 16 x i1> %pg)
75 ret <vscale x 16 x i1> %out
78 define <vscale x 8 x i1> @reinterpret_bool_to_h(<vscale x 16 x i1> %pg) {
79 ; CHECK-LABEL: reinterpret_bool_to_h:
82 %out = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
83 ret <vscale x 8 x i1> %out
86 define <vscale x 4 x i1> @reinterpret_bool_to_s(<vscale x 16 x i1> %pg) {
87 ; CHECK-LABEL: reinterpret_bool_to_s:
90 %out = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
91 ret <vscale x 4 x i1> %out
94 define <vscale x 2 x i1> @reinterpret_bool_to_d(<vscale x 16 x i1> %pg) {
95 ; CHECK-LABEL: reinterpret_bool_to_d:
98 %out = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
99 ret <vscale x 2 x i1> %out
102 define <vscale x 1 x i1> @reinterpret_bool_to_q(<vscale x 16 x i1> %pg) {
103 ; CHECK-LABEL: reinterpret_bool_to_q:
106 %out = call <vscale x 1 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv1i1(<vscale x 16 x i1> %pg)
107 ret <vscale x 1 x i1> %out
110 define target("aarch64.svcount") @reinterpret_bool_to_svcount(<vscale x 16 x i1> %pg) "target-features"="+sme2" {
111 ; CHECK-LABEL: reinterpret_bool_to_svcount:
114 %out = call target("aarch64.svcount") @llvm.aarch64.sve.convert.from.svbool.taarch64.svcountt(<vscale x 16 x i1> %pg)
115 ret target("aarch64.svcount") %out
119 ; Reinterpreting a ptrue should not introduce an `and` instruction.
120 define <vscale x 16 x i1> @reinterpret_ptrue() {
121 ; CHECK-LABEL: reinterpret_ptrue:
123 ; CHECK-NEXT: ptrue p0.h
125 %in = tail call <vscale x 8 x i1> @llvm.aarch64.sve.ptrue.nxv8i1(i32 31)
126 %out = tail call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv8i1(<vscale x 8 x i1> %in)
127 ret <vscale x 16 x i1> %out
130 ; Reinterpreting a comparison not introduce an `and` instruction.
131 define <vscale x 16 x i1> @reinterpret_cmpgt(<vscale x 8 x i1> %p, <vscale x 8 x i16> %a, <vscale x 8 x i16> %b) {
132 ; CHECK-LABEL: reinterpret_cmpgt:
134 ; CHECK-NEXT: cmpgt p0.h, p0/z, z0.h, z1.h
136 %1 = tail call <vscale x 8 x i1> @llvm.aarch64.sve.cmpgt.nxv8i16(<vscale x 8 x i1> %p, <vscale x 8 x i16> %a, <vscale x 8 x i16> %b)
137 %2 = tail call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv8i1(<vscale x 8 x i1> %1)
138 ret <vscale x 16 x i1> %2
141 ; The first reinterpret should prevent the second one from being simplified as a nop
142 define <vscale x 16 x i1> @chained_reinterpret() {
143 ; CHECK-LABEL: chained_reinterpret:
145 ; CHECK-NEXT: ptrue p0.d
147 %in = tail call <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 31)
148 %cast2 = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %in)
149 %out = tail call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv2i1(<vscale x 2 x i1> %cast2)
150 ret <vscale x 16 x i1> %out
153 define <vscale x 16 x i1> @reinterpret_scalar_bool_h(i1 %x){
154 ; CHECK-LABEL: reinterpret_scalar_bool_h:
156 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
157 ; CHECK-NEXT: sbfx x8, x0, #0, #1
158 ; CHECK-NEXT: whilelo p0.h, xzr, x8
160 %.splatinsert = insertelement <vscale x 8 x i1> poison, i1 %x, i64 0
161 %.splat = shufflevector <vscale x 8 x i1> %.splatinsert, <vscale x 8 x i1> poison, <vscale x 8 x i32> zeroinitializer
162 %out = tail call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv8i1(<vscale x 8 x i1> %.splat)
163 ret <vscale x 16 x i1> %out
166 define <vscale x 16 x i1> @reinterpret_scalar_bool_s(i1 %x){
167 ; CHECK-LABEL: reinterpret_scalar_bool_s:
169 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
170 ; CHECK-NEXT: sbfx x8, x0, #0, #1
171 ; CHECK-NEXT: whilelo p0.s, xzr, x8
173 %.splatinsert = insertelement <vscale x 4 x i1> poison, i1 %x, i64 0
174 %.splat = shufflevector <vscale x 4 x i1> %.splatinsert, <vscale x 4 x i1> poison, <vscale x 4 x i32> zeroinitializer
175 %out = tail call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv4i1(<vscale x 4 x i1> %.splat)
176 ret <vscale x 16 x i1> %out
179 define <vscale x 16 x i1> @reinterpret_scalar_bool_q(i1 %x){
180 ; CHECK-LABEL: reinterpret_scalar_bool_q:
182 ; CHECK-NEXT: // kill: def $w0 killed $w0 def $x0
183 ; CHECK-NEXT: sbfx x8, x0, #0, #1
184 ; CHECK-NEXT: whilelo p0.d, xzr, x8
186 %.splatinsert = insertelement <vscale x 2 x i1> poison, i1 %x, i64 0
187 %.splat = shufflevector <vscale x 2 x i1> %.splatinsert, <vscale x 2 x i1> poison, <vscale x 2 x i32> zeroinitializer
188 %out = tail call <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv2i1(<vscale x 2 x i1> %.splat)
189 ret <vscale x 16 x i1> %out
193 declare <vscale x 8 x i1> @llvm.aarch64.sve.ptrue.nxv8i1(i32 immarg)
194 declare <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 immarg)
195 declare <vscale x 8 x i1> @llvm.aarch64.sve.cmpgt.nxv8i16(<vscale x 8 x i1>, <vscale x 8 x i16>, <vscale x 8 x i16>)
197 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv16i1(<vscale x 16 x i1>)
198 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv8i1(<vscale x 8 x i1>)
199 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv4i1(<vscale x 4 x i1>)
200 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv2i1(<vscale x 2 x i1>)
201 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv1i1(<vscale x 1 x i1>)
202 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.taarch64.svcountt(target("aarch64.svcount"))
204 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv16i1(<vscale x 16 x i1>)
205 declare <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1>)
206 declare <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1>)
207 declare <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1>)
208 declare <vscale x 1 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv1i1(<vscale x 16 x i1>)
209 declare target("aarch64.svcount") @llvm.aarch64.sve.convert.from.svbool.taarch64.svcountt(<vscale x 16 x i1>)