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 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
4 // 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
5 // 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 - -x c++ %s | FileCheck %s
6 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null
7 #include <arm_sve.h>
8
9 #ifdef SVE_OVERLOADED_FORMS
10 // A simple used,unused... macro, long enough to represent any SVE builtin.
11 #define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
12 #else
13 #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
14 #endif
15
test_svprfd(svbool_t pg,const void * base)16 void test_svprfd(svbool_t pg, const void *base)
17 {
18 // CHECK-LABEL: test_svprfd
19 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
20 // CHECK: @llvm.aarch64.sve.prf.nxv2i1(<vscale x 2 x i1> %[[PG]], i8* %base, i32 0)
21 return svprfd(pg, base, SV_PLDL1KEEP);
22 }
23
test_svprfd_1(svbool_t pg,const void * base)24 void test_svprfd_1(svbool_t pg, const void *base)
25 {
26 // CHECK-LABEL: test_svprfd_1
27 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
28 // CHECK: @llvm.aarch64.sve.prf.nxv2i1(<vscale x 2 x i1> %[[PG]], i8* %base, i32 1)
29 return svprfd(pg, base, SV_PLDL1STRM);
30 }
31
test_svprfd_2(svbool_t pg,const void * base)32 void test_svprfd_2(svbool_t pg, const void *base)
33 {
34 // CHECK-LABEL: test_svprfd_2
35 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
36 // CHECK: @llvm.aarch64.sve.prf.nxv2i1(<vscale x 2 x i1> %[[PG]], i8* %base, i32 2)
37 return svprfd(pg, base, SV_PLDL2KEEP);
38 }
39
test_svprfd_3(svbool_t pg,const void * base)40 void test_svprfd_3(svbool_t pg, const void *base)
41 {
42 // CHECK-LABEL: test_svprfd_3
43 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
44 // CHECK: @llvm.aarch64.sve.prf.nxv2i1(<vscale x 2 x i1> %[[PG]], i8* %base, i32 3)
45 return svprfd(pg, base, SV_PLDL2STRM);
46 }
47
test_svprfd_4(svbool_t pg,const void * base)48 void test_svprfd_4(svbool_t pg, const void *base)
49 {
50 // CHECK-LABEL: test_svprfd_4
51 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
52 // CHECK: @llvm.aarch64.sve.prf.nxv2i1(<vscale x 2 x i1> %[[PG]], i8* %base, i32 4)
53 return svprfd(pg, base, SV_PLDL3KEEP);
54 }
55
test_svprfd_5(svbool_t pg,const void * base)56 void test_svprfd_5(svbool_t pg, const void *base)
57 {
58 // CHECK-LABEL: test_svprfd_5
59 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
60 // CHECK: @llvm.aarch64.sve.prf.nxv2i1(<vscale x 2 x i1> %[[PG]], i8* %base, i32 5)
61 return svprfd(pg, base, SV_PLDL3STRM);
62 }
63
test_svprfd_6(svbool_t pg,const void * base)64 void test_svprfd_6(svbool_t pg, const void *base)
65 {
66 // CHECK-LABEL: test_svprfd_6
67 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
68 // CHECK: @llvm.aarch64.sve.prf.nxv2i1(<vscale x 2 x i1> %[[PG]], i8* %base, i32 8)
69 return svprfd(pg, base, SV_PSTL1KEEP);
70 }
71
test_svprfd_7(svbool_t pg,const void * base)72 void test_svprfd_7(svbool_t pg, const void *base)
73 {
74 // CHECK-LABEL: test_svprfd_7
75 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
76 // CHECK: @llvm.aarch64.sve.prf.nxv2i1(<vscale x 2 x i1> %[[PG]], i8* %base, i32 9)
77 return svprfd(pg, base, SV_PSTL1STRM);
78 }
79
test_svprfd_8(svbool_t pg,const void * base)80 void test_svprfd_8(svbool_t pg, const void *base)
81 {
82 // CHECK-LABEL: test_svprfd_8
83 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
84 // CHECK: @llvm.aarch64.sve.prf.nxv2i1(<vscale x 2 x i1> %[[PG]], i8* %base, i32 10)
85 return svprfd(pg, base, SV_PSTL2KEEP);
86 }
87
test_svprfd_9(svbool_t pg,const void * base)88 void test_svprfd_9(svbool_t pg, const void *base)
89 {
90 // CHECK-LABEL: test_svprfd_9
91 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
92 // CHECK: @llvm.aarch64.sve.prf.nxv2i1(<vscale x 2 x i1> %[[PG]], i8* %base, i32 11)
93 return svprfd(pg, base, SV_PSTL2STRM);
94 }
95
test_svprfd_10(svbool_t pg,const void * base)96 void test_svprfd_10(svbool_t pg, const void *base)
97 {
98 // CHECK-LABEL: test_svprfd_10
99 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
100 // CHECK: @llvm.aarch64.sve.prf.nxv2i1(<vscale x 2 x i1> %[[PG]], i8* %base, i32 12)
101 return svprfd(pg, base, SV_PSTL3KEEP);
102 }
103
test_svprfd_11(svbool_t pg,const void * base)104 void test_svprfd_11(svbool_t pg, const void *base)
105 {
106 // CHECK-LABEL: test_svprfd_11
107 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
108 // CHECK: @llvm.aarch64.sve.prf.nxv2i1(<vscale x 2 x i1> %[[PG]], i8* %base, i32 13)
109 return svprfd(pg, base, SV_PSTL3STRM);
110 }
111
test_svprfd_vnum(svbool_t pg,const void * base,int64_t vnum)112 void test_svprfd_vnum(svbool_t pg, const void *base, int64_t vnum)
113 {
114 // CHECK-LABEL: test_svprfd_vnum
115 // CHECK-DAG: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
116 // CHECK-DAG: %[[BASE:.*]] = bitcast i8* %base to <vscale x 2 x i64>*
117 // CHECK-DAG: %[[GEP:.*]] = getelementptr <vscale x 2 x i64>, <vscale x 2 x i64>* %[[BASE]], i64 %vnum
118 // CHECK-DAG: %[[I8_BASE:.*]] = bitcast <vscale x 2 x i64>* %[[GEP]] to i8*
119 // CHECK: @llvm.aarch64.sve.prf.nxv2i1(<vscale x 2 x i1> %[[PG]], i8* %[[I8_BASE]], i32 0)
120 return svprfd_vnum(pg, base, vnum, SV_PLDL1KEEP);
121 }
122
test_svprfd_gather_u32base(svbool_t pg,svuint32_t bases)123 void test_svprfd_gather_u32base(svbool_t pg, svuint32_t bases)
124 {
125 // CHECK-LABEL: test_svprfd_gather_u32base
126 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
127 // CHECK: call void @llvm.aarch64.sve.prfd.gather.scalar.offset.nxv4i32(<vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %bases, i64 0, i32 0)
128 // CHECK: ret void
129 return SVE_ACLE_FUNC(svprfd_gather,_u32base,,)(pg, bases, SV_PLDL1KEEP);
130 }
131
test_svprfd_gather_u64base(svbool_t pg,svuint64_t bases)132 void test_svprfd_gather_u64base(svbool_t pg, svuint64_t bases)
133 {
134 // CHECK-LABEL: test_svprfd_gather_u64base
135 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
136 // CHECK: call void @llvm.aarch64.sve.prfd.gather.scalar.offset.nxv2i64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %bases, i64 0, i32 0)
137 // CHECK: ret void
138 return SVE_ACLE_FUNC(svprfd_gather,_u64base,,)(pg, bases, SV_PLDL1KEEP);
139 }
140
test_svprfd_gather_s32index(svbool_t pg,const void * base,svint32_t indices)141 void test_svprfd_gather_s32index(svbool_t pg, const void *base, svint32_t indices)
142 {
143 // CHECK-LABEL: test_svprfd_gather_s32index
144 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
145 // CHECK: call void @llvm.aarch64.sve.prfd.gather.sxtw.index.nxv4i32(<vscale x 4 x i1> %[[PG]], i8* %base, <vscale x 4 x i32> %indices, i32 0)
146 // CHECK: ret void
147 return SVE_ACLE_FUNC(svprfd_gather_,s32,index,)(pg, base, indices, SV_PLDL1KEEP);
148 }
149
test_svprfd_gather_s64index(svbool_t pg,const void * base,svint64_t indices)150 void test_svprfd_gather_s64index(svbool_t pg, const void *base, svint64_t indices)
151 {
152 // CHECK-LABEL: test_svprfd_gather_s64index
153 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
154 // CHECK: call void @llvm.aarch64.sve.prfd.gather.index.nxv2i64(<vscale x 2 x i1> %[[PG]], i8* %base, <vscale x 2 x i64> %indices, i32 0)
155 // CHECK: ret void
156 return SVE_ACLE_FUNC(svprfd_gather_,s64,index,)(pg, base, indices, SV_PLDL1KEEP);
157 }
158
test_svprfd_gather_u32index(svbool_t pg,const void * base,svuint32_t indices)159 void test_svprfd_gather_u32index(svbool_t pg, const void *base, svuint32_t indices)
160 {
161 // CHECK-LABEL: test_svprfd_gather_u32index
162 // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
163 // CHECK: call void @llvm.aarch64.sve.prfd.gather.uxtw.index.nxv4i32(<vscale x 4 x i1> %[[PG]], i8* %base, <vscale x 4 x i32> %indices, i32 0)
164 // CHECK: ret void
165 return SVE_ACLE_FUNC(svprfd_gather_,u32,index,)(pg, base, indices, SV_PLDL1KEEP);
166 }
167
test_svprfd_gather_u64index(svbool_t pg,const void * base,svuint64_t indices)168 void test_svprfd_gather_u64index(svbool_t pg, const void *base, svuint64_t indices)
169 {
170 // CHECK-LABEL: test_svprfd_gather_u64index
171 // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
172 // CHECK: call void @llvm.aarch64.sve.prfd.gather.index.nxv2i64(<vscale x 2 x i1> %[[PG]], i8* %base, <vscale x 2 x i64> %indices, i32 0)
173 // CHECK: ret void
174 return SVE_ACLE_FUNC(svprfd_gather_,u64,index,)(pg, base, indices, SV_PLDL1KEEP);
175 }
176
test_svprfd_gather_u32base_index(svbool_t pg,svuint32_t bases,int64_t index)177 void test_svprfd_gather_u32base_index(svbool_t pg, svuint32_t bases, int64_t index)
178 {
179 // CHECK-LABEL: test_svprfd_gather_u32base_index
180 // CHECK-DAG: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
181 // CHECK-DAG: %[[SHL:.*]] = shl i64 %index, 3
182 // CHECK: call void @llvm.aarch64.sve.prfd.gather.scalar.offset.nxv4i32(<vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %bases, i64 %[[SHL]], i32 0)
183 // CHECK: ret void
184 return SVE_ACLE_FUNC(svprfd_gather,_u32base,_index,)(pg, bases, index, SV_PLDL1KEEP);
185 }
186
test_svprfd_gather_u64base_index(svbool_t pg,svuint64_t bases,int64_t index)187 void test_svprfd_gather_u64base_index(svbool_t pg, svuint64_t bases, int64_t index)
188 {
189 // CHECK-LABEL: test_svprfd_gather_u64base_index
190 // CHECK-DAG: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
191 // CHECK-DAG: %[[SHL:.*]] = shl i64 %index, 3
192 // CHECK: call void @llvm.aarch64.sve.prfd.gather.scalar.offset.nxv2i64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %bases, i64 %[[SHL]], i32 0)
193 // CHECK: ret void
194 return SVE_ACLE_FUNC(svprfd_gather,_u64base,_index,)(pg, bases, index, SV_PLDL1KEEP);
195 }
196