1 ; NOTE: Assertions have been autogenerated by utils/update_llc_test_checks.py
2 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sve < %s | FileCheck %s
3 ; RUN: llc -mtriple=aarch64-linux-gnu -mattr=+sme < %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 declare <vscale x 8 x i1> @llvm.aarch64.sve.ptrue.nxv8i1(i32 immarg)
154 declare <vscale x 16 x i1> @llvm.aarch64.sve.ptrue.nxv16i1(i32 immarg)
155 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>)
157 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv16i1(<vscale x 16 x i1>)
158 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv8i1(<vscale x 8 x i1>)
159 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv4i1(<vscale x 4 x i1>)
160 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv2i1(<vscale x 2 x i1>)
161 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.nxv1i1(<vscale x 1 x i1>)
162 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.to.svbool.taarch64.svcountt(target("aarch64.svcount"))
164 declare <vscale x 16 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv16i1(<vscale x 16 x i1>)
165 declare <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1>)
166 declare <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1>)
167 declare <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1>)
168 declare <vscale x 1 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv1i1(<vscale x 16 x i1>)
169 declare target("aarch64.svcount") @llvm.aarch64.sve.convert.from.svbool.taarch64.svcountt(<vscale x 16 x i1>)