1 // REQUIRES: aarch64-registered-target
2 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
4 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null 2>%t
5 // RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
6
7 // If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it.
8 // ASM-NOT: warning
9 #include <arm_sve.h>
10
11 #ifdef SVE_OVERLOADED_FORMS
12 // A simple used,unused... macro, long enough to represent any SVE builtin.
13 #define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
14 #else
15 #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
16 #endif
17
test_svprfb(svbool_t pg,const void * base)18 void test_svprfb(svbool_t pg, const void *base)
19 {
20 // CHECK-LABEL: test_svprfb
21 // CHECK: @llvm.aarch64.sve.prf.nxv16i1(<vscale x 16 x i1> %pg, i8* %base, i32 0)
22 return svprfb(pg, base, SV_PLDL1KEEP);
23 }
24
test_svprfb_1(svbool_t pg,const void * base)25 void test_svprfb_1(svbool_t pg, const void *base)
26 {
27 // CHECK-LABEL: test_svprfb_1
28 // CHECK: @llvm.aarch64.sve.prf.nxv16i1(<vscale x 16 x i1> %pg, i8* %base, i32 1)
29 return svprfb(pg, base, SV_PLDL1STRM);
30 }
31
test_svprfb_2(svbool_t pg,const void * base)32 void test_svprfb_2(svbool_t pg, const void *base)
33 {
34 // CHECK-LABEL: test_svprfb_2
35 // CHECK: @llvm.aarch64.sve.prf.nxv16i1(<vscale x 16 x i1> %pg, i8* %base, i32 2)
36 return svprfb(pg, base, SV_PLDL2KEEP);
37 }
38
test_svprfb_3(svbool_t pg,const void * base)39 void test_svprfb_3(svbool_t pg, const void *base)
40 {
41 // CHECK-LABEL: test_svprfb_3
42 // CHECK: @llvm.aarch64.sve.prf.nxv16i1(<vscale x 16 x i1> %pg, i8* %base, i32 3)
43 return svprfb(pg, base, SV_PLDL2STRM);
44 }
45
test_svprfb_4(svbool_t pg,const void * base)46 void test_svprfb_4(svbool_t pg, const void *base)
47 {
48 // CHECK-LABEL: test_svprfb_4
49 // CHECK: @llvm.aarch64.sve.prf.nxv16i1(<vscale x 16 x i1> %pg, i8* %base, i32 4)
50 return svprfb(pg, base, SV_PLDL3KEEP);
51 }
52
test_svprfb_5(svbool_t pg,const void * base)53 void test_svprfb_5(svbool_t pg, const void *base)
54 {
55 // CHECK-LABEL: test_svprfb_5
56 // CHECK: @llvm.aarch64.sve.prf.nxv16i1(<vscale x 16 x i1> %pg, i8* %base, i32 5)
57 return svprfb(pg, base, SV_PLDL3STRM);
58 }
59
test_svprfb_6(svbool_t pg,const void * base)60 void test_svprfb_6(svbool_t pg, const void *base)
61 {
62 // CHECK-LABEL: test_svprfb_6
63 // CHECK: @llvm.aarch64.sve.prf.nxv16i1(<vscale x 16 x i1> %pg, i8* %base, i32 8)
64 return svprfb(pg, base, SV_PSTL1KEEP);
65 }
66
test_svprfb_7(svbool_t pg,const void * base)67 void test_svprfb_7(svbool_t pg, const void *base)
68 {
69 // CHECK-LABEL: test_svprfb_7
70 // CHECK: @llvm.aarch64.sve.prf.nxv16i1(<vscale x 16 x i1> %pg, i8* %base, i32 9)
71 return svprfb(pg, base, SV_PSTL1STRM);
72 }
73
test_svprfb_8(svbool_t pg,const void * base)74 void test_svprfb_8(svbool_t pg, const void *base)
75 {
76 // CHECK-LABEL: test_svprfb_8
77 // CHECK: @llvm.aarch64.sve.prf.nxv16i1(<vscale x 16 x i1> %pg, i8* %base, i32 10)
78 return svprfb(pg, base, SV_PSTL2KEEP);
79 }
80
test_svprfb_9(svbool_t pg,const void * base)81 void test_svprfb_9(svbool_t pg, const void *base)
82 {
83 // CHECK-LABEL: test_svprfb_9
84 // CHECK: @llvm.aarch64.sve.prf.nxv16i1(<vscale x 16 x i1> %pg, i8* %base, i32 11)
85 return svprfb(pg, base, SV_PSTL2STRM);
86 }
87
test_svprfb_10(svbool_t pg,const void * base)88 void test_svprfb_10(svbool_t pg, const void *base)
89 {
90 // CHECK-LABEL: test_svprfb_10
91 // CHECK: @llvm.aarch64.sve.prf.nxv16i1(<vscale x 16 x i1> %pg, i8* %base, i32 12)
92 return svprfb(pg, base, SV_PSTL3KEEP);
93 }
94
test_svprfb_11(svbool_t pg,const void * base)95 void test_svprfb_11(svbool_t pg, const void *base)
96 {
97 // CHECK-LABEL: test_svprfb_11
98 // CHECK: @llvm.aarch64.sve.prf.nxv16i1(<vscale x 16 x i1> %pg, i8* %base, i32 13)
99 return svprfb(pg, base, SV_PSTL3STRM);
100 }
101
test_svprfb_vnum(svbool_t pg,const void * base,int64_t vnum)102 void test_svprfb_vnum(svbool_t pg, const void *base, int64_t vnum)
103 {
104 // CHECK-LABEL: test_svprfb_vnum
105 // CHECK: %[[BASE:.*]] = bitcast i8* %base to <vscale x 16 x i8>*
106 // CHECK: %[[GEP:.*]] = getelementptr <vscale x 16 x i8>, <vscale x 16 x i8>* %[[BASE]], i64 %vnum, i64 0
107 // CHECK: @llvm.aarch64.sve.prf.nxv16i1(<vscale x 16 x i1> %pg, i8* %[[GEP]], i32 0)
108 return svprfb_vnum(pg, base, vnum, SV_PLDL1KEEP);
109 }
110
test_svprfb_gather_u32base(svbool_t pg,svuint32_t bases)111 void test_svprfb_gather_u32base(svbool_t pg, svuint32_t bases)
112 {
113 // CHECK-LABEL: test_svprfb_gather_u32base
114 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
115 // CHECK: call void @llvm.aarch64.sve.prfb.gather.scalar.offset.nxv4i32(<vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %bases, i64 0, i32 0)
116 // CHECK: ret void
117 return SVE_ACLE_FUNC(svprfb_gather,_u32base,,)(pg, bases, SV_PLDL1KEEP);
118 }
119
test_svprfb_gather_u64base(svbool_t pg,svuint64_t bases)120 void test_svprfb_gather_u64base(svbool_t pg, svuint64_t bases)
121 {
122 // CHECK-LABEL: test_svprfb_gather_u64base
123 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
124 // CHECK: call void @llvm.aarch64.sve.prfb.gather.scalar.offset.nxv2i64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %bases, i64 0, i32 0)
125 // CHECK: ret void
126 return SVE_ACLE_FUNC(svprfb_gather,_u64base,,)(pg, bases, SV_PLDL1KEEP);
127 }
128
test_svprfb_gather_s32offset(svbool_t pg,const void * base,svint32_t offsets)129 void test_svprfb_gather_s32offset(svbool_t pg, const void *base, svint32_t offsets)
130 {
131 // CHECK-LABEL: test_svprfb_gather_s32offset
132 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
133 // CHECK: call void @llvm.aarch64.sve.prfb.gather.sxtw.index.nxv4i32(<vscale x 4 x i1> %[[PG]], i8* %base, <vscale x 4 x i32> %offsets, i32 0)
134 // CHECK: ret void
135 return SVE_ACLE_FUNC(svprfb_gather_,s32,offset,)(pg, base, offsets, SV_PLDL1KEEP);
136 }
137
test_svprfb_gather_s64offset(svbool_t pg,const void * base,svint64_t offsets)138 void test_svprfb_gather_s64offset(svbool_t pg, const void *base, svint64_t offsets)
139 {
140 // CHECK-LABEL: test_svprfb_gather_s64offset
141 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
142 // CHECK: call void @llvm.aarch64.sve.prfb.gather.index.nxv2i64(<vscale x 2 x i1> %[[PG]], i8* %base, <vscale x 2 x i64> %offsets, i32 0)
143 // CHECK: ret void
144 return SVE_ACLE_FUNC(svprfb_gather_,s64,offset,)(pg, base, offsets, SV_PLDL1KEEP);
145 }
146
test_svprfb_gather_u32offset(svbool_t pg,const void * base,svuint32_t offsets)147 void test_svprfb_gather_u32offset(svbool_t pg, const void *base, svuint32_t offsets)
148 {
149 // CHECK-LABEL: test_svprfb_gather_u32offset
150 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
151 // CHECK: call void @llvm.aarch64.sve.prfb.gather.uxtw.index.nxv4i32(<vscale x 4 x i1> %[[PG]], i8* %base, <vscale x 4 x i32> %offsets, i32 0)
152 // CHECK: ret void
153 return SVE_ACLE_FUNC(svprfb_gather_,u32,offset,)(pg, base, offsets, SV_PLDL1KEEP);
154 }
155
test_svprfb_gather_u64offset(svbool_t pg,const void * base,svuint64_t offsets)156 void test_svprfb_gather_u64offset(svbool_t pg, const void *base, svuint64_t offsets)
157 {
158 // CHECK-LABEL: test_svprfb_gather_u64offset
159 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
160 // CHECK: call void @llvm.aarch64.sve.prfb.gather.index.nxv2i64(<vscale x 2 x i1> %[[PG]], i8* %base, <vscale x 2 x i64> %offsets, i32 0)
161 // CHECK: ret void
162 return SVE_ACLE_FUNC(svprfb_gather_,u64,offset,)(pg, base, offsets, SV_PLDL1KEEP);
163 }
164
test_svprfb_gather_u32base_offset(svbool_t pg,svuint32_t bases,int64_t offset)165 void test_svprfb_gather_u32base_offset(svbool_t pg, svuint32_t bases, int64_t offset)
166 {
167 // CHECK-LABEL: test_svprfb_gather_u32base_offset
168 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
169 // CHECK: call void @llvm.aarch64.sve.prfb.gather.scalar.offset.nxv4i32(<vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %bases, i64 %offset, i32 0)
170 // CHECK: ret void
171 return svprfb_gather_u32base_offset(pg, bases, offset, SV_PLDL1KEEP);
172 return SVE_ACLE_FUNC(svprfb_gather,_u32base,_offset,)(pg, bases, offset, SV_PLDL1KEEP);
173 }
174
test_svprfb_gather_u64base_offset(svbool_t pg,svuint64_t bases,int64_t offset)175 void test_svprfb_gather_u64base_offset(svbool_t pg, svuint64_t bases, int64_t offset)
176 {
177 // CHECK-LABEL: test_svprfb_gather_u64base_offset
178 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
179 // CHECK: call void @llvm.aarch64.sve.prfb.gather.scalar.offset.nxv2i64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %bases, i64 %offset, i32 0)
180 // CHECK: ret void
181 return SVE_ACLE_FUNC(svprfb_gather,_u64base,_offset,)(pg, bases, offset, SV_PLDL1KEEP);
182 }
183