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_svldnt1sw_gather_u64base_s64(svbool_t pg,svuint64_t bases)15 svint64_t test_svldnt1sw_gather_u64base_s64(svbool_t pg, svuint64_t bases) {
16   // CHECK-LABEL: test_svldnt1sw_gather_u64base_s64
17   // CHECK: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
18   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i32> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv2i32.nxv2i64(<vscale x 2 x i1> [[PG]], <vscale x 2 x i64> %bases, i64 0)
19   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
20   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
21   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_s64'}}
22   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_u64base_s64'}}
23   return SVE_ACLE_FUNC(svldnt1sw_gather, _u64base, _s64, )(pg, bases);
24 }
25 
test_svldnt1sw_gather_u64base_u64(svbool_t pg,svuint64_t bases)26 svuint64_t test_svldnt1sw_gather_u64base_u64(svbool_t pg, svuint64_t bases) {
27   // CHECK-LABEL: test_svldnt1sw_gather_u64base_u64
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 i32> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv2i32.nxv2i64(<vscale x 2 x i1> [[PG]], <vscale x 2 x i64> %bases, i64 0)
30   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
31   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
32   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_u64'}}
33   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_u64base_u64'}}
34   return SVE_ACLE_FUNC(svldnt1sw_gather, _u64base, _u64, )(pg, bases);
35 }
36 
test_svldnt1sw_gather_s64offset_s64(svbool_t pg,const int32_t * base,svint64_t offsets)37 svint64_t test_svldnt1sw_gather_s64offset_s64(svbool_t pg, const int32_t *base, svint64_t offsets) {
38   // CHECK-LABEL: test_svldnt1sw_gather_s64offset_s64
39   // CHECK: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
40   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i32> @llvm.aarch64.sve.ldnt1.gather.nxv2i32(<vscale x 2 x i1> [[PG]], i32* %base, <vscale x 2 x i64> %offsets)
41   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
42   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
43   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_offset_s64'}}
44   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_s64offset_s64'}}
45   return SVE_ACLE_FUNC(svldnt1sw_gather_, s64, offset_s64, )(pg, base, offsets);
46 }
47 
test_svldnt1sw_gather_s64offset_u64(svbool_t pg,const int32_t * base,svint64_t offsets)48 svuint64_t test_svldnt1sw_gather_s64offset_u64(svbool_t pg, const int32_t *base, svint64_t offsets) {
49   // CHECK-LABEL: test_svldnt1sw_gather_s64offset_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 i32> @llvm.aarch64.sve.ldnt1.gather.nxv2i32(<vscale x 2 x i1> [[PG]], i32* %base, <vscale x 2 x i64> %offsets)
52   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
53   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
54   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_offset_u64'}}
55   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_s64offset_u64'}}
56   return SVE_ACLE_FUNC(svldnt1sw_gather_, s64, offset_u64, )(pg, base, offsets);
57 }
58 
test_svldnt1sw_gather_u64offset_s64(svbool_t pg,const int32_t * base,svuint64_t offsets)59 svint64_t test_svldnt1sw_gather_u64offset_s64(svbool_t pg, const int32_t *base, svuint64_t offsets) {
60   // CHECK-LABEL: test_svldnt1sw_gather_u64offset_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 i32> @llvm.aarch64.sve.ldnt1.gather.nxv2i32(<vscale x 2 x i1> [[PG]], i32* %base, <vscale x 2 x i64> %offsets)
63   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
64   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
65   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_offset_s64'}}
66   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_u64offset_s64'}}
67   return SVE_ACLE_FUNC(svldnt1sw_gather_, u64, offset_s64, )(pg, base, offsets);
68 }
69 
test_svldnt1sw_gather_u64offset_u64(svbool_t pg,const int32_t * base,svuint64_t offsets)70 svuint64_t test_svldnt1sw_gather_u64offset_u64(svbool_t pg, const int32_t *base, svuint64_t offsets) {
71   // CHECK-LABEL: test_svldnt1sw_gather_u64offset_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 i32> @llvm.aarch64.sve.ldnt1.gather.nxv2i32(<vscale x 2 x i1> [[PG]], i32* %base, <vscale x 2 x i64> %offsets)
74   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
75   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
76   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_offset_u64'}}
77   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_u64offset_u64'}}
78   return SVE_ACLE_FUNC(svldnt1sw_gather_, u64, offset_u64, )(pg, base, offsets);
79 }
80 
test_svldnt1sw_gather_u64base_offset_s64(svbool_t pg,svuint64_t bases,int64_t offset)81 svint64_t test_svldnt1sw_gather_u64base_offset_s64(svbool_t pg, svuint64_t bases, int64_t offset) {
82   // CHECK-LABEL: test_svldnt1sw_gather_u64base_offset_s64
83   // CHECK: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
84   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i32> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv2i32.nxv2i64(<vscale x 2 x i1> [[PG]], <vscale x 2 x i64> %bases, i64 %offset)
85   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
86   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
87   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_offset_s64'}}
88   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_u64base_offset_s64'}}
89   return SVE_ACLE_FUNC(svldnt1sw_gather, _u64base, _offset_s64, )(pg, bases, offset);
90 }
91 
test_svldnt1sw_gather_u64base_offset_u64(svbool_t pg,svuint64_t bases,int64_t offset)92 svuint64_t test_svldnt1sw_gather_u64base_offset_u64(svbool_t pg, svuint64_t bases, int64_t offset) {
93   // CHECK-LABEL: test_svldnt1sw_gather_u64base_offset_u64
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 i32> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv2i32.nxv2i64(<vscale x 2 x i1> [[PG]], <vscale x 2 x i64> %bases, i64 %offset)
96   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
97   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
98   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_offset_u64'}}
99   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_u64base_offset_u64'}}
100   return SVE_ACLE_FUNC(svldnt1sw_gather, _u64base, _offset_u64, )(pg, bases, offset);
101 }
102 
test_svldnt1sw_gather_s64index_s64(svbool_t pg,const int32_t * base,svint64_t indices)103 svint64_t test_svldnt1sw_gather_s64index_s64(svbool_t pg, const int32_t *base, svint64_t indices) {
104   // CHECK-LABEL: test_svldnt1sw_gather_s64index_s64
105   // CHECK: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
106   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i32> @llvm.aarch64.sve.ldnt1.gather.index.nxv2i32(<vscale x 2 x i1> [[PG]], i32* %base, <vscale x 2 x i64> %indices)
107   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
108   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
109   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_index_s64'}}
110   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_s64index_s64'}}
111   return SVE_ACLE_FUNC(svldnt1sw_gather_, s64, index_s64, )(pg, base, indices);
112 }
113 
test_svldnt1sw_gather_s64index_u64(svbool_t pg,const int32_t * base,svint64_t indices)114 svuint64_t test_svldnt1sw_gather_s64index_u64(svbool_t pg, const int32_t *base, svint64_t indices) {
115   // CHECK-LABEL: test_svldnt1sw_gather_s64index_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 i32> @llvm.aarch64.sve.ldnt1.gather.index.nxv2i32(<vscale x 2 x i1> [[PG]], i32* %base, <vscale x 2 x i64> %indices)
118   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
119   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
120   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_index_u64'}}
121   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_s64index_u64'}}
122   return SVE_ACLE_FUNC(svldnt1sw_gather_, s64, index_u64, )(pg, base, indices);
123 }
124 
test_svldnt1sw_gather_u64index_s64(svbool_t pg,const int32_t * base,svuint64_t indices)125 svint64_t test_svldnt1sw_gather_u64index_s64(svbool_t pg, const int32_t *base, svuint64_t indices) {
126   // CHECK-LABEL: test_svldnt1sw_gather_u64index_s64
127   // CHECK: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
128   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i32> @llvm.aarch64.sve.ldnt1.gather.index.nxv2i32(<vscale x 2 x i1> [[PG]], i32* %base, <vscale x 2 x i64> %indices)
129   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
130   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
131   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_index_s64'}}
132   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_u64index_s64'}}
133   return SVE_ACLE_FUNC(svldnt1sw_gather_, u64, index_s64, )(pg, base, indices);
134 }
135 
test_svldnt1sw_gather_u64index_u64(svbool_t pg,const int32_t * base,svuint64_t indices)136 svuint64_t test_svldnt1sw_gather_u64index_u64(svbool_t pg, const int32_t *base, svuint64_t indices) {
137   // CHECK-LABEL: test_svldnt1sw_gather_u64index_u64
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 i32> @llvm.aarch64.sve.ldnt1.gather.index.nxv2i32(<vscale x 2 x i1> [[PG]], i32* %base, <vscale x 2 x i64> %indices)
140   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
141   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
142   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_index_u64'}}
143   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_u64index_u64'}}
144   return SVE_ACLE_FUNC(svldnt1sw_gather_, u64, index_u64, )(pg, base, indices);
145 }
146 
test_svldnt1sw_gather_u64base_index_s64(svbool_t pg,svuint64_t bases,int64_t index)147 svint64_t test_svldnt1sw_gather_u64base_index_s64(svbool_t pg, svuint64_t bases, int64_t index) {
148   // CHECK-LABEL: test_svldnt1sw_gather_u64base_index_s64
149   // CHECK-DAG: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
150   // CHECK-DAG: [[SHL:%.*]] = shl i64 %index, 2
151   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i32> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv2i32.nxv2i64(<vscale x 2 x i1> [[PG]], <vscale x 2 x i64> %bases, i64 [[SHL]])
152   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
153   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
154   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_index_s64'}}
155   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_u64base_index_s64'}}
156   return SVE_ACLE_FUNC(svldnt1sw_gather, _u64base, _index_s64, )(pg, bases, index);
157 }
158 
test_svldnt1sw_gather_u64base_index_u64(svbool_t pg,svuint64_t bases,int64_t index)159 svuint64_t test_svldnt1sw_gather_u64base_index_u64(svbool_t pg, svuint64_t bases, int64_t index) {
160   // CHECK-LABEL: test_svldnt1sw_gather_u64base_index_u64
161   // CHECK-DAG: [[PG:%.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
162   // CHECK-DAG: [[SHL:%.*]] = shl i64 %index, 2
163   // CHECK: [[LOAD:%.*]] = call <vscale x 2 x i32> @llvm.aarch64.sve.ldnt1.gather.scalar.offset.nxv2i32.nxv2i64(<vscale x 2 x i1> [[PG]], <vscale x 2 x i64> %bases, i64 [[SHL]])
164   // CHECK: [[SEXT:%.*]] = sext <vscale x 2 x i32> [[LOAD]] to <vscale x 2 x i64>
165   // CHECK: ret <vscale x 2 x i64> [[SEXT]]
166   // overload-warning@+2 {{implicit declaration of function 'svldnt1sw_gather_index_u64'}}
167   // expected-warning@+1 {{implicit declaration of function 'svldnt1sw_gather_u64base_index_u64'}}
168   return SVE_ACLE_FUNC(svldnt1sw_gather, _u64base, _index_u64, )(pg, bases, index);
169 }
170