1 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
2 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve2 -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 -fsyntax-only -verify -verify-ignore-unexpected=error %s
4 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify=overload -verify-ignore-unexpected=error %s
5 
6 #include <arm_sve.h>
7 
8 #ifdef SVE_OVERLOADED_FORMS
9 // A simple used,unused... macro, long enough to represent any SVE builtin.
10 #define SVE_ACLE_FUNC(A1, A2_UNUSED, A3, A4_UNUSED) A1##A3
11 #else
12 #define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
13 #endif
14 
test_svldnt1sb_gather_u32base_s32(svbool_t pg,svuint32_t bases)15 svint32_t test_svldnt1sb_gather_u32base_s32(svbool_t pg, svuint32_t bases) {
16   // CHECK-LABEL: test_svldnt1sb_gather_u32base_s32
17   // CHECK: [[PG:%.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
18   // CHECK: [[LOAD:%.*]] = call <vscale x 4 x i8> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv4i8.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> %bases, i64 0)
19   // CHECK: [[SEXT:%.*]] = sext <vscale x 4 x i8> [[LOAD]] to <vscale x 4 x i32>
20   // CHECK: ret <vscale x 4 x i32> [[SEXT]]
21   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_s32'}}
22   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_u32base_s32'}}
23   return SVE_ACLE_FUNC(svldnt1sb_gather, _u32base, _s32, )(pg, bases);
24 }
25 
test_svldnt1sb_gather_u64base_s64(svbool_t pg,svuint64_t bases)26 svint64_t test_svldnt1sb_gather_u64base_s64(svbool_t pg, svuint64_t bases) {
27   // CHECK-LABEL: test_svldnt1sb_gather_u64base_s64
28   // CHECK: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
29   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i8> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv2i8.nxv2i64(<vscale x 2 x i1> [[PG]], <vscale x 2 x i64> %bases, i64 0)
30   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i8> [[LOAD]] to <vscale x 2 x i64>
31   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
32   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_s64'}}
33   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_u64base_s64'}}
34   return SVE_ACLE_FUNC(svldnt1sb_gather, _u64base, _s64, )(pg, bases);
35 }
36 
test_svldnt1sb_gather_u32base_u32(svbool_t pg,svuint32_t bases)37 svuint32_t test_svldnt1sb_gather_u32base_u32(svbool_t pg, svuint32_t bases) {
38   // CHECK-LABEL: test_svldnt1sb_gather_u32base_u32
39   // CHECK: [[PG:%.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
40   // CHECK: [[LOAD:%.*]] = call <vscale x 4 x i8> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv4i8.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> %bases, i64 0)
41   // CHECK: [[SEXT:%.*]] = sext <vscale x 4 x i8> [[LOAD]] to <vscale x 4 x i32>
42   // CHECK: ret <vscale x 4 x i32> [[SEXT]]
43   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_u32'}}
44   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_u32base_u32'}}
45   return SVE_ACLE_FUNC(svldnt1sb_gather, _u32base, _u32, )(pg, bases);
46 }
47 
test_svldnt1sb_gather_u64base_u64(svbool_t pg,svuint64_t bases)48 svuint64_t test_svldnt1sb_gather_u64base_u64(svbool_t pg, svuint64_t bases) {
49   // CHECK-LABEL: test_svldnt1sb_gather_u64base_u64
50   // CHECK: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
51   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i8> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv2i8.nxv2i64(<vscale x 2 x i1> [[PG]], <vscale x 2 x i64> %bases, i64 0)
52   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i8> [[LOAD]] to <vscale x 2 x i64>
53   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
54   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_u64'}}
55   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_u64base_u64'}}
56   return SVE_ACLE_FUNC(svldnt1sb_gather, _u64base, _u64, )(pg, bases);
57 }
58 
test_svldnt1sb_gather_s64offset_s64(svbool_t pg,const int8_t * base,svint64_t offsets)59 svint64_t test_svldnt1sb_gather_s64offset_s64(svbool_t pg, const int8_t *base, svint64_t offsets) {
60   // CHECK-LABEL: test_svldnt1sb_gather_s64offset_s64
61   // CHECK: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
62   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i8> @llvm.aarch64.sve.ldnt1.gather.nxv2i8(<vscale x 2 x i1> [[PG]], i8* %base, <vscale x 2 x i64> %offsets)
63   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i8> [[LOAD]] to <vscale x 2 x i64>
64   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
65   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_offset_s64'}}
66   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_s64offset_s64'}}
67   return SVE_ACLE_FUNC(svldnt1sb_gather_, s64, offset_s64, )(pg, base, offsets);
68 }
69 
test_svldnt1sb_gather_s64offset_u64(svbool_t pg,const int8_t * base,svint64_t offsets)70 svuint64_t test_svldnt1sb_gather_s64offset_u64(svbool_t pg, const int8_t *base, svint64_t offsets) {
71   // CHECK-LABEL: test_svldnt1sb_gather_s64offset_u64
72   // CHECK: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
73   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i8> @llvm.aarch64.sve.ldnt1.gather.nxv2i8(<vscale x 2 x i1> [[PG]], i8* %base, <vscale x 2 x i64> %offsets)
74   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i8> [[LOAD]] to <vscale x 2 x i64>
75   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
76   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_offset_u64'}}
77   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_s64offset_u64'}}
78   return SVE_ACLE_FUNC(svldnt1sb_gather_, s64, offset_u64, )(pg, base, offsets);
79 }
80 
test_svldnt1sb_gather_u32offset_s32(svbool_t pg,const int8_t * base,svuint32_t offsets)81 svint32_t test_svldnt1sb_gather_u32offset_s32(svbool_t pg, const int8_t *base, svuint32_t offsets) {
82   // CHECK-LABEL: test_svldnt1sb_gather_u32offset_s32
83   // CHECK: [[PG:%.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
84   // CHECK: [[LOAD:%.*]] = call <vscale x 4 x i8> @llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4i8(<vscale x 4 x i1> [[PG]], i8* %base, <vscale x 4 x i32> %offsets)
85   // CHECK: [[SEXT:%.*]] = sext <vscale x 4 x i8> [[LOAD]] to <vscale x 4 x i32>
86   // CHECK: ret <vscale x 4 x i32> [[SEXT]]
87   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_offset_s32'}}
88   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_u32offset_s32'}}
89   return SVE_ACLE_FUNC(svldnt1sb_gather_, u32, offset_s32, )(pg, base, offsets);
90 }
91 
test_svldnt1sb_gather_u64offset_s64(svbool_t pg,const int8_t * base,svuint64_t offsets)92 svint64_t test_svldnt1sb_gather_u64offset_s64(svbool_t pg, const int8_t *base, svuint64_t offsets) {
93   // CHECK-LABEL: test_svldnt1sb_gather_u64offset_s64
94   // CHECK: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
95   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i8> @llvm.aarch64.sve.ldnt1.gather.nxv2i8(<vscale x 2 x i1> [[PG]], i8* %base, <vscale x 2 x i64> %offsets)
96   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i8> [[LOAD]] to <vscale x 2 x i64>
97   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
98   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_offset_s64'}}
99   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_u64offset_s64'}}
100   return SVE_ACLE_FUNC(svldnt1sb_gather_, u64, offset_s64, )(pg, base, offsets);
101 }
102 
test_svldnt1sb_gather_u32offset_u32(svbool_t pg,const int8_t * base,svuint32_t offsets)103 svuint32_t test_svldnt1sb_gather_u32offset_u32(svbool_t pg, const int8_t *base, svuint32_t offsets) {
104   // CHECK-LABEL: test_svldnt1sb_gather_u32offset_u32
105   // CHECK: [[PG:%.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
106   // CHECK: [[LOAD:%.*]] = call <vscale x 4 x i8> @llvm.aarch64.sve.ldnt1.gather.uxtw.nxv4i8(<vscale x 4 x i1> [[PG]], i8* %base, <vscale x 4 x i32> %offsets)
107   // CHECK: [[SEXT:%.*]] = sext <vscale x 4 x i8> [[LOAD]] to <vscale x 4 x i32>
108   // CHECK: ret <vscale x 4 x i32> [[SEXT]]
109   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_offset_u32'}}
110   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_u32offset_u32'}}
111   return SVE_ACLE_FUNC(svldnt1sb_gather_, u32, offset_u32, )(pg, base, offsets);
112 }
113 
test_svldnt1sb_gather_u64offset_u64(svbool_t pg,const int8_t * base,svuint64_t offsets)114 svuint64_t test_svldnt1sb_gather_u64offset_u64(svbool_t pg, const int8_t *base, svuint64_t offsets) {
115   // CHECK-LABEL: test_svldnt1sb_gather_u64offset_u64
116   // CHECK: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
117   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i8> @llvm.aarch64.sve.ldnt1.gather.nxv2i8(<vscale x 2 x i1> [[PG]], i8* %base, <vscale x 2 x i64> %offsets)
118   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i8> [[LOAD]] to <vscale x 2 x i64>
119   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
120   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_offset_u64'}}
121   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_u64offset_u64'}}
122   return SVE_ACLE_FUNC(svldnt1sb_gather_, u64, offset_u64, )(pg, base, offsets);
123 }
124 
test_svldnt1sb_gather_u32base_offset_s32(svbool_t pg,svuint32_t bases,int64_t offset)125 svint32_t test_svldnt1sb_gather_u32base_offset_s32(svbool_t pg, svuint32_t bases, int64_t offset) {
126   // CHECK-LABEL: test_svldnt1sb_gather_u32base_offset_s32
127   // CHECK: [[PG:%.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
128   // CHECK: [[LOAD:%.*]] = call <vscale x 4 x i8> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv4i8.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> %bases, i64 %offset)
129   // CHECK: [[SEXT:%.*]] = sext <vscale x 4 x i8> [[LOAD]] to <vscale x 4 x i32>
130   // CHECK: ret <vscale x 4 x i32> [[SEXT]]
131   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_offset_s32'}}
132   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_u32base_offset_s32'}}
133   return SVE_ACLE_FUNC(svldnt1sb_gather, _u32base, _offset_s32, )(pg, bases, offset);
134 }
135 
test_svldnt1sb_gather_u64base_offset_s64(svbool_t pg,svuint64_t bases,int64_t offset)136 svint64_t test_svldnt1sb_gather_u64base_offset_s64(svbool_t pg, svuint64_t bases, int64_t offset) {
137   // CHECK-LABEL: test_svldnt1sb_gather_u64base_offset_s64
138   // CHECK: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
139   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i8> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv2i8.nxv2i64(<vscale x 2 x i1> [[PG]], <vscale x 2 x i64> %bases, i64 %offset)
140   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i8> [[LOAD]] to <vscale x 2 x i64>
141   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
142   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_offset_s64'}}
143   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_u64base_offset_s64'}}
144   return SVE_ACLE_FUNC(svldnt1sb_gather, _u64base, _offset_s64, )(pg, bases, offset);
145 }
146 
test_svldnt1sb_gather_u32base_offset_u32(svbool_t pg,svuint32_t bases,int64_t offset)147 svuint32_t test_svldnt1sb_gather_u32base_offset_u32(svbool_t pg, svuint32_t bases, int64_t offset) {
148   // CHECK-LABEL: test_svldnt1sb_gather_u32base_offset_u32
149   // CHECK: [[PG:%.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
150   // CHECK: [[LOAD:%.*]] = call <vscale x 4 x i8> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv4i8.nxv4i32(<vscale x 4 x i1> [[PG]], <vscale x 4 x i32> %bases, i64 %offset)
151   // CHECK: [[SEXT:%.*]] = sext <vscale x 4 x i8> [[LOAD]] to <vscale x 4 x i32>
152   // CHECK: ret <vscale x 4 x i32> [[SEXT]]
153   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_offset_u32'}}
154   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_u32base_offset_u32'}}
155   return SVE_ACLE_FUNC(svldnt1sb_gather, _u32base, _offset_u32, )(pg, bases, offset);
156 }
157 
test_svldnt1sb_gather_u64base_offset_u64(svbool_t pg,svuint64_t bases,int64_t offset)158 svuint64_t test_svldnt1sb_gather_u64base_offset_u64(svbool_t pg, svuint64_t bases, int64_t offset) {
159   // CHECK-LABEL: test_svldnt1sb_gather_u64base_offset_u64
160   // CHECK: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
161   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i8> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv2i8.nxv2i64(<vscale x 2 x i1> [[PG]], <vscale x 2 x i64> %bases, i64 %offset)
162   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i8> [[LOAD]] to <vscale x 2 x i64>
163   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
164   // overload-warning@+2 {{implicit declaration of function 'svldnt1sb_gather_offset_u64'}}
165   // expected-warning@+1 {{implicit declaration of function 'svldnt1sb_gather_u64base_offset_u64'}}
166   return SVE_ACLE_FUNC(svldnt1sb_gather, _u64base, _offset_u64, )(pg, bases, offset);
167 }
168