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_svprfh(svbool_t pg,const void * base)16 void test_svprfh(svbool_t pg, const void *base)
17 {
18   // CHECK-LABEL: test_svprfh
19   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
20   // CHECK: @llvm.aarch64.sve.prf.nxv8i1(<vscale x 8 x i1> %[[PG]], i8* %base, i32 0)
21   return svprfh(pg, base, SV_PLDL1KEEP);
22 }
23 
test_svprfh_1(svbool_t pg,const void * base)24 void test_svprfh_1(svbool_t pg, const void *base)
25 {
26   // CHECK-LABEL: test_svprfh_1
27   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
28   // CHECK: @llvm.aarch64.sve.prf.nxv8i1(<vscale x 8 x i1> %[[PG]], i8* %base, i32 1)
29   return svprfh(pg, base, SV_PLDL1STRM);
30 }
31 
test_svprfh_2(svbool_t pg,const void * base)32 void test_svprfh_2(svbool_t pg, const void *base)
33 {
34   // CHECK-LABEL: test_svprfh_2
35   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
36   // CHECK: @llvm.aarch64.sve.prf.nxv8i1(<vscale x 8 x i1> %[[PG]], i8* %base, i32 2)
37   return svprfh(pg, base, SV_PLDL2KEEP);
38 }
39 
test_svprfh_3(svbool_t pg,const void * base)40 void test_svprfh_3(svbool_t pg, const void *base)
41 {
42   // CHECK-LABEL: test_svprfh_3
43   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
44   // CHECK: @llvm.aarch64.sve.prf.nxv8i1(<vscale x 8 x i1> %[[PG]], i8* %base, i32 3)
45   return svprfh(pg, base, SV_PLDL2STRM);
46 }
47 
test_svprfh_4(svbool_t pg,const void * base)48 void test_svprfh_4(svbool_t pg, const void *base)
49 {
50   // CHECK-LABEL: test_svprfh_4
51   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
52   // CHECK: @llvm.aarch64.sve.prf.nxv8i1(<vscale x 8 x i1> %[[PG]], i8* %base, i32 4)
53   return svprfh(pg, base, SV_PLDL3KEEP);
54 }
55 
test_svprfh_5(svbool_t pg,const void * base)56 void test_svprfh_5(svbool_t pg, const void *base)
57 {
58   // CHECK-LABEL: test_svprfh_5
59   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
60   // CHECK: @llvm.aarch64.sve.prf.nxv8i1(<vscale x 8 x i1> %[[PG]], i8* %base, i32 5)
61   return svprfh(pg, base, SV_PLDL3STRM);
62 }
63 
test_svprfh_6(svbool_t pg,const void * base)64 void test_svprfh_6(svbool_t pg, const void *base)
65 {
66   // CHECK-LABEL: test_svprfh_6
67   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
68   // CHECK: @llvm.aarch64.sve.prf.nxv8i1(<vscale x 8 x i1> %[[PG]], i8* %base, i32 8)
69   return svprfh(pg, base, SV_PSTL1KEEP);
70 }
71 
test_svprfh_7(svbool_t pg,const void * base)72 void test_svprfh_7(svbool_t pg, const void *base)
73 {
74   // CHECK-LABEL: test_svprfh_7
75   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
76   // CHECK: @llvm.aarch64.sve.prf.nxv8i1(<vscale x 8 x i1> %[[PG]], i8* %base, i32 9)
77   return svprfh(pg, base, SV_PSTL1STRM);
78 }
79 
test_svprfh_8(svbool_t pg,const void * base)80 void test_svprfh_8(svbool_t pg, const void *base)
81 {
82   // CHECK-LABEL: test_svprfh_8
83   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
84   // CHECK: @llvm.aarch64.sve.prf.nxv8i1(<vscale x 8 x i1> %[[PG]], i8* %base, i32 10)
85   return svprfh(pg, base, SV_PSTL2KEEP);
86 }
87 
test_svprfh_9(svbool_t pg,const void * base)88 void test_svprfh_9(svbool_t pg, const void *base)
89 {
90   // CHECK-LABEL: test_svprfh_9
91   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
92   // CHECK: @llvm.aarch64.sve.prf.nxv8i1(<vscale x 8 x i1> %[[PG]], i8* %base, i32 11)
93   return svprfh(pg, base, SV_PSTL2STRM);
94 }
95 
test_svprfh_10(svbool_t pg,const void * base)96 void test_svprfh_10(svbool_t pg, const void *base)
97 {
98   // CHECK-LABEL: test_svprfh_10
99   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
100   // CHECK: @llvm.aarch64.sve.prf.nxv8i1(<vscale x 8 x i1> %[[PG]], i8* %base, i32 12)
101   return svprfh(pg, base, SV_PSTL3KEEP);
102 }
103 
test_svprfh_11(svbool_t pg,const void * base)104 void test_svprfh_11(svbool_t pg, const void *base)
105 {
106   // CHECK-LABEL: test_svprfh_11
107   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
108   // CHECK: @llvm.aarch64.sve.prf.nxv8i1(<vscale x 8 x i1> %[[PG]], i8* %base, i32 13)
109   return svprfh(pg, base, SV_PSTL3STRM);
110 }
111 
test_svprfh_vnum(svbool_t pg,const void * base,int64_t vnum)112 void test_svprfh_vnum(svbool_t pg, const void *base, int64_t vnum)
113 {
114   // CHECK-LABEL: test_svprfh_vnum
115   // CHECK-DAG: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
116   // CHECK-DAG: %[[BASE:.*]] = bitcast i8* %base to <vscale x 8 x i16>*
117   // CHECK-DAG: %[[GEP:.*]] = getelementptr <vscale x 8 x i16>, <vscale x 8 x i16>* %[[BASE]], i64 %vnum
118   // CHECK-DAG: %[[I8_BASE:.*]] = bitcast <vscale x 8 x i16>* %[[GEP]] to i8*
119   // CHECK: @llvm.aarch64.sve.prf.nxv8i1(<vscale x 8 x i1> %[[PG]], i8* %[[I8_BASE]], i32 0)
120   return svprfh_vnum(pg, base, vnum, SV_PLDL1KEEP);
121 }
122 
test_svprfh_gather_u32base(svbool_t pg,svuint32_t bases)123 void test_svprfh_gather_u32base(svbool_t pg, svuint32_t bases)
124 {
125   // CHECK-LABEL: test_svprfh_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.prfh.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(svprfh_gather,_u32base,,)(pg, bases, SV_PLDL1KEEP);
130 }
131 
test_svprfh_gather_u64base(svbool_t pg,svuint64_t bases)132 void test_svprfh_gather_u64base(svbool_t pg, svuint64_t bases)
133 {
134   // CHECK-LABEL: test_svprfh_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.prfh.gather.scalar.offset.nxv2i64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %bases, i64 0, i32 0)
137   return SVE_ACLE_FUNC(svprfh_gather,_u64base,,)(pg, bases, SV_PLDL1KEEP);
138 }
139 
test_svprfh_gather_s32index(svbool_t pg,const void * base,svint32_t indices)140 void test_svprfh_gather_s32index(svbool_t pg, const void *base, svint32_t indices)
141 {
142   // CHECK-LABEL: test_svprfh_gather_s32index
143   // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
144   // CHECK: call void @llvm.aarch64.sve.prfh.gather.sxtw.index.nxv4i32(<vscale x 4 x i1> %[[PG]], i8* %base, <vscale x 4 x i32> %indices, i32 0)
145   // CHECK: ret void
146   return SVE_ACLE_FUNC(svprfh_gather_,s32,index,)(pg, base, indices, SV_PLDL1KEEP);
147 }
148 
test_svprfh_gather_s64index(svbool_t pg,const void * base,svint64_t indices)149 void test_svprfh_gather_s64index(svbool_t pg, const void *base, svint64_t indices)
150 {
151   // CHECK-LABEL: test_svprfh_gather_s64index
152   // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
153   // CHECK: call void @llvm.aarch64.sve.prfh.gather.index.nxv2i64(<vscale x 2 x i1> %[[PG]], i8* %base, <vscale x 2 x i64> %indices, i32 0)
154   return SVE_ACLE_FUNC(svprfh_gather_,s64,index,)(pg, base, indices, SV_PLDL1KEEP);
155 }
156 
test_svprfh_gather_u32index(svbool_t pg,const void * base,svuint32_t indices)157 void test_svprfh_gather_u32index(svbool_t pg, const void *base, svuint32_t indices)
158 {
159   // CHECK-LABEL: test_svprfh_gather_u32index
160   // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
161   // CHECK: call void @llvm.aarch64.sve.prfh.gather.uxtw.index.nxv4i32(<vscale x 4 x i1> %[[PG]], i8* %base, <vscale x 4 x i32> %indices, i32 0)
162   // CHECK: ret void
163   return SVE_ACLE_FUNC(svprfh_gather_,u32,index,)(pg, base, indices, SV_PLDL1KEEP);
164 }
165 
test_svprfh_gather_u64index(svbool_t pg,const void * base,svuint64_t indices)166 void test_svprfh_gather_u64index(svbool_t pg, const void *base, svuint64_t indices)
167 {
168   // CHECK-LABEL: test_svprfh_gather_u64index
169   // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
170   // CHECK: call void @llvm.aarch64.sve.prfh.gather.index.nxv2i64(<vscale x 2 x i1> %[[PG]], i8* %base, <vscale x 2 x i64> %indices, i32 0)
171   // CHECK: ret void
172   return SVE_ACLE_FUNC(svprfh_gather_,u64,index,)(pg, base, indices, SV_PLDL1KEEP);
173 }
174 
test_svprfh_gather_u32base_index(svbool_t pg,svuint32_t bases,int64_t index)175 void test_svprfh_gather_u32base_index(svbool_t pg, svuint32_t bases, int64_t index)
176 {
177   // CHECK-LABEL: test_svprfh_gather_u32base_index
178   // CHECK-DAG: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
179   // CHECK-DAG: %[[SHL:.*]] = shl i64 %index, 1
180   // CHECK: call void @llvm.aarch64.sve.prfh.gather.scalar.offset.nxv4i32(<vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %bases, i64 %[[SHL]], i32 0)
181   // CHECK: ret void
182   return SVE_ACLE_FUNC(svprfh_gather,_u32base,_index,)(pg, bases, index, SV_PLDL1KEEP);
183 }
184 
test_svprfh_gather_u64base_index(svbool_t pg,svuint64_t bases,int64_t index)185 void test_svprfh_gather_u64base_index(svbool_t pg, svuint64_t bases, int64_t index)
186 {
187   // CHECK-LABEL: test_svprfh_gather_u64base_index
188   // CHECK-DAG: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
189   // CHECK-DAG: %[[SHL:.*]] = shl i64 %index, 1
190   // CHECK: call void @llvm.aarch64.sve.prfh.gather.scalar.offset.nxv2i64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %bases, i64 %[[SHL]], i32 0)
191   // CHECK: ret void
192   return SVE_ACLE_FUNC(svprfh_gather,_u64base,_index,)(pg, bases, index, SV_PLDL1KEEP);
193 }
194