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 -triple aarch64-none-linux-gnu -target-feature +sve2 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
3 // 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
4 // 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 - -x c++ %s | FileCheck %s
5 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -fsyntax-only -verify -verify-ignore-unexpected=error %s
6 // 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
7 
8 #include <arm_sve.h>
9 
10 #ifdef SVE_OVERLOADED_FORMS
11 // A simple used,unused... macro, long enough to represent any SVE builtin.
12 #define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
13 #else
14 #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
15 #endif
16 
test_svcadd_s8(svint8_t op1,svint8_t op2)17 svint8_t test_svcadd_s8(svint8_t op1, svint8_t op2)
18 {
19   // CHECK-LABEL: test_svcadd_s8
20   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.cadd.x.nxv16i8(<vscale x 16 x i8> %op1, <vscale x 16 x i8> %op2, i32 90)
21   // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
22   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
23   // expected-warning@+1 {{implicit declaration of function 'svcadd_s8'}}
24   return SVE_ACLE_FUNC(svcadd,_s8,,)(op1, op2, 90);
25 }
26 
test_svcadd_s8_1(svint8_t op1,svint8_t op2)27 svint8_t test_svcadd_s8_1(svint8_t op1, svint8_t op2)
28 {
29   // CHECK-LABEL: test_svcadd_s8_1
30   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.cadd.x.nxv16i8(<vscale x 16 x i8> %op1, <vscale x 16 x i8> %op2, i32 270)
31   // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
32   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
33   // expected-warning@+1 {{implicit declaration of function 'svcadd_s8'}}
34   return SVE_ACLE_FUNC(svcadd,_s8,,)(op1, op2, 270);
35 }
36 
test_svcadd_s16(svint16_t op1,svint16_t op2)37 svint16_t test_svcadd_s16(svint16_t op1, svint16_t op2)
38 {
39   // CHECK-LABEL: test_svcadd_s16
40   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.cadd.x.nxv8i16(<vscale x 8 x i16> %op1, <vscale x 8 x i16> %op2, i32 90)
41   // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
42   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
43   // expected-warning@+1 {{implicit declaration of function 'svcadd_s16'}}
44   return SVE_ACLE_FUNC(svcadd,_s16,,)(op1, op2, 90);
45 }
46 
test_svcadd_s16_1(svint16_t op1,svint16_t op2)47 svint16_t test_svcadd_s16_1(svint16_t op1, svint16_t op2)
48 {
49   // CHECK-LABEL: test_svcadd_s16_1
50   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.cadd.x.nxv8i16(<vscale x 8 x i16> %op1, <vscale x 8 x i16> %op2, i32 270)
51   // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
52   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
53   // expected-warning@+1 {{implicit declaration of function 'svcadd_s16'}}
54   return SVE_ACLE_FUNC(svcadd,_s16,,)(op1, op2, 270);
55 }
56 
test_svcadd_s32(svint32_t op1,svint32_t op2)57 svint32_t test_svcadd_s32(svint32_t op1, svint32_t op2)
58 {
59   // CHECK-LABEL: test_svcadd_s32
60   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.cadd.x.nxv4i32(<vscale x 4 x i32> %op1, <vscale x 4 x i32> %op2, i32 90)
61   // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
62   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
63   // expected-warning@+1 {{implicit declaration of function 'svcadd_s32'}}
64   return SVE_ACLE_FUNC(svcadd,_s32,,)(op1, op2, 90);
65 }
66 
test_svcadd_s32_1(svint32_t op1,svint32_t op2)67 svint32_t test_svcadd_s32_1(svint32_t op1, svint32_t op2)
68 {
69   // CHECK-LABEL: test_svcadd_s32_1
70   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.cadd.x.nxv4i32(<vscale x 4 x i32> %op1, <vscale x 4 x i32> %op2, i32 270)
71   // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
72   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
73   // expected-warning@+1 {{implicit declaration of function 'svcadd_s32'}}
74   return SVE_ACLE_FUNC(svcadd,_s32,,)(op1, op2, 270);
75 }
76 
test_svcadd_s64(svint64_t op1,svint64_t op2)77 svint64_t test_svcadd_s64(svint64_t op1, svint64_t op2)
78 {
79   // CHECK-LABEL: test_svcadd_s64
80   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.cadd.x.nxv2i64(<vscale x 2 x i64> %op1, <vscale x 2 x i64> %op2, i32 90)
81   // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
82   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
83   // expected-warning@+1 {{implicit declaration of function 'svcadd_s64'}}
84   return SVE_ACLE_FUNC(svcadd,_s64,,)(op1, op2, 90);
85 }
86 
test_svcadd_s64_1(svint64_t op1,svint64_t op2)87 svint64_t test_svcadd_s64_1(svint64_t op1, svint64_t op2)
88 {
89   // CHECK-LABEL: test_svcadd_s64_1
90   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.cadd.x.nxv2i64(<vscale x 2 x i64> %op1, <vscale x 2 x i64> %op2, i32 270)
91   // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
92   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
93   // expected-warning@+1 {{implicit declaration of function 'svcadd_s64'}}
94   return SVE_ACLE_FUNC(svcadd,_s64,,)(op1, op2, 270);
95 }
96 
test_svcadd_u8(svuint8_t op1,svuint8_t op2)97 svuint8_t test_svcadd_u8(svuint8_t op1, svuint8_t op2)
98 {
99   // CHECK-LABEL: test_svcadd_u8
100   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.cadd.x.nxv16i8(<vscale x 16 x i8> %op1, <vscale x 16 x i8> %op2, i32 90)
101   // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
102   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
103   // expected-warning@+1 {{implicit declaration of function 'svcadd_u8'}}
104   return SVE_ACLE_FUNC(svcadd,_u8,,)(op1, op2, 90);
105 }
106 
test_svcadd_u8_1(svuint8_t op1,svuint8_t op2)107 svuint8_t test_svcadd_u8_1(svuint8_t op1, svuint8_t op2)
108 {
109   // CHECK-LABEL: test_svcadd_u8_1
110   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.cadd.x.nxv16i8(<vscale x 16 x i8> %op1, <vscale x 16 x i8> %op2, i32 270)
111   // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
112   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
113   // expected-warning@+1 {{implicit declaration of function 'svcadd_u8'}}
114   return SVE_ACLE_FUNC(svcadd,_u8,,)(op1, op2, 270);
115 }
116 
test_svcadd_u16(svuint16_t op1,svuint16_t op2)117 svuint16_t test_svcadd_u16(svuint16_t op1, svuint16_t op2)
118 {
119   // CHECK-LABEL: test_svcadd_u16
120   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.cadd.x.nxv8i16(<vscale x 8 x i16> %op1, <vscale x 8 x i16> %op2, i32 90)
121   // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
122   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
123   // expected-warning@+1 {{implicit declaration of function 'svcadd_u16'}}
124   return SVE_ACLE_FUNC(svcadd,_u16,,)(op1, op2, 90);
125 }
126 
test_svcadd_u16_1(svuint16_t op1,svuint16_t op2)127 svuint16_t test_svcadd_u16_1(svuint16_t op1, svuint16_t op2)
128 {
129   // CHECK-LABEL: test_svcadd_u16_1
130   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.cadd.x.nxv8i16(<vscale x 8 x i16> %op1, <vscale x 8 x i16> %op2, i32 270)
131   // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
132   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
133   // expected-warning@+1 {{implicit declaration of function 'svcadd_u16'}}
134   return SVE_ACLE_FUNC(svcadd,_u16,,)(op1, op2, 270);
135 }
136 
test_svcadd_u32(svuint32_t op1,svuint32_t op2)137 svuint32_t test_svcadd_u32(svuint32_t op1, svuint32_t op2)
138 {
139   // CHECK-LABEL: test_svcadd_u32
140   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.cadd.x.nxv4i32(<vscale x 4 x i32> %op1, <vscale x 4 x i32> %op2, i32 90)
141   // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
142   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
143   // expected-warning@+1 {{implicit declaration of function 'svcadd_u32'}}
144   return SVE_ACLE_FUNC(svcadd,_u32,,)(op1, op2, 90);
145 }
146 
test_svcadd_u32_1(svuint32_t op1,svuint32_t op2)147 svuint32_t test_svcadd_u32_1(svuint32_t op1, svuint32_t op2)
148 {
149   // CHECK-LABEL: test_svcadd_u32_1
150   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.cadd.x.nxv4i32(<vscale x 4 x i32> %op1, <vscale x 4 x i32> %op2, i32 270)
151   // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
152   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
153   // expected-warning@+1 {{implicit declaration of function 'svcadd_u32'}}
154   return SVE_ACLE_FUNC(svcadd,_u32,,)(op1, op2, 270);
155 }
156 
test_svcadd_u64(svuint64_t op1,svuint64_t op2)157 svuint64_t test_svcadd_u64(svuint64_t op1, svuint64_t op2)
158 {
159   // CHECK-LABEL: test_svcadd_u64
160   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.cadd.x.nxv2i64(<vscale x 2 x i64> %op1, <vscale x 2 x i64> %op2, i32 90)
161   // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
162   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
163   // expected-warning@+1 {{implicit declaration of function 'svcadd_u64'}}
164   return SVE_ACLE_FUNC(svcadd,_u64,,)(op1, op2, 90);
165 }
166 
test_svcadd_u64_1(svuint64_t op1,svuint64_t op2)167 svuint64_t test_svcadd_u64_1(svuint64_t op1, svuint64_t op2)
168 {
169   // CHECK-LABEL: test_svcadd_u64_1
170   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.cadd.x.nxv2i64(<vscale x 2 x i64> %op1, <vscale x 2 x i64> %op2, i32 270)
171   // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
172   // overload-warning@+2 {{implicit declaration of function 'svcadd'}}
173   // expected-warning@+1 {{implicit declaration of function 'svcadd_u64'}}
174   return SVE_ACLE_FUNC(svcadd,_u64,,)(op1, op2, 270);
175 }
176