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_svtbl2_s8(svint8x2_t data,svuint8_t indices)15 svint8_t test_svtbl2_s8(svint8x2_t data, svuint8_t indices)
16 {
17   // CHECK-LABEL: test_svtbl2_s8
18   // CHECK-DAG: %[[V0:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.tuple.get.nxv16i8.nxv32i8(<vscale x 32 x i8> %data, i32 0)
19   // CHECK-DAG: %[[V1:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.tuple.get.nxv16i8.nxv32i8(<vscale x 32 x i8> %data, i32 1)
20   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.tbl2.nxv16i8(<vscale x 16 x i8> %[[V0]], <vscale x 16 x i8> %[[V1]], <vscale x 16 x i8> %indices)
21   // CHECK-NEXT: ret <vscale x 16 x i8> %[[INTRINSIC]]
22   // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
23   // expected-warning@+1 {{implicit declaration of function 'svtbl2_s8'}}
24   return SVE_ACLE_FUNC(svtbl2,_s8,,)(data, indices);
25 }
26 
test_svtbl2_s16(svint16x2_t data,svuint16_t indices)27 svint16_t test_svtbl2_s16(svint16x2_t data, svuint16_t indices)
28 {
29   // CHECK-LABEL: test_svtbl2_s16
30   // CHECK-DAG: %[[V0:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.tuple.get.nxv8i16.nxv16i16(<vscale x 16 x i16> %data, i32 0)
31   // CHECK-DAG: %[[V1:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.tuple.get.nxv8i16.nxv16i16(<vscale x 16 x i16> %data, i32 1)
32   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.tbl2.nxv8i16(<vscale x 8 x i16> %[[V0]], <vscale x 8 x i16> %[[V1]], <vscale x 8 x i16> %indices)
33   // CHECK-NEXT: ret <vscale x 8 x i16> %[[INTRINSIC]]
34   // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
35   // expected-warning@+1 {{implicit declaration of function 'svtbl2_s16'}}
36   return SVE_ACLE_FUNC(svtbl2,_s16,,)(data, indices);
37 }
38 
test_svtbl2_s32(svint32x2_t data,svuint32_t indices)39 svint32_t test_svtbl2_s32(svint32x2_t data, svuint32_t indices)
40 {
41   // CHECK-LABEL: test_svtbl2_s32
42   // CHECK-DAG: %[[V0:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.tuple.get.nxv4i32.nxv8i32(<vscale x 8 x i32> %data, i32 0)
43   // CHECK-DAG: %[[V1:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.tuple.get.nxv4i32.nxv8i32(<vscale x 8 x i32> %data, i32 1)
44   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.tbl2.nxv4i32(<vscale x 4 x i32> %[[V0]], <vscale x 4 x i32> %[[V1]], <vscale x 4 x i32> %indices)
45   // CHECK-NEXT: ret <vscale x 4 x i32> %[[INTRINSIC]]
46   // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
47   // expected-warning@+1 {{implicit declaration of function 'svtbl2_s32'}}
48   return SVE_ACLE_FUNC(svtbl2,_s32,,)(data, indices);
49 }
50 
test_svtbl2_s64(svint64x2_t data,svuint64_t indices)51 svint64_t test_svtbl2_s64(svint64x2_t data, svuint64_t indices)
52 {
53   // CHECK-LABEL: test_svtbl2_s64
54   // CHECK-DAG: %[[V0:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.tuple.get.nxv2i64.nxv4i64(<vscale x 4 x i64> %data, i32 0)
55   // CHECK-DAG: %[[V1:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.tuple.get.nxv2i64.nxv4i64(<vscale x 4 x i64> %data, i32 1)
56   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.tbl2.nxv2i64(<vscale x 2 x i64> %[[V0]], <vscale x 2 x i64> %[[V1]], <vscale x 2 x i64> %indices)
57   // CHECK-NEXT: ret <vscale x 2 x i64> %[[INTRINSIC]]
58   // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
59   // expected-warning@+1 {{implicit declaration of function 'svtbl2_s64'}}
60   return SVE_ACLE_FUNC(svtbl2,_s64,,)(data, indices);
61 }
62 
test_svtbl2_u8(svuint8x2_t data,svuint8_t indices)63 svuint8_t test_svtbl2_u8(svuint8x2_t data, svuint8_t indices)
64 {
65   // CHECK-LABEL: test_svtbl2_u8
66   // CHECK-DAG: %[[V0:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.tuple.get.nxv16i8.nxv32i8(<vscale x 32 x i8> %data, i32 0)
67   // CHECK-DAG: %[[V1:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.tuple.get.nxv16i8.nxv32i8(<vscale x 32 x i8> %data, i32 1)
68   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.tbl2.nxv16i8(<vscale x 16 x i8> %[[V0]], <vscale x 16 x i8> %[[V1]], <vscale x 16 x i8> %indices)
69   // CHECK-NEXT: ret <vscale x 16 x i8> %[[INTRINSIC]]
70   // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
71   // expected-warning@+1 {{implicit declaration of function 'svtbl2_u8'}}
72   return SVE_ACLE_FUNC(svtbl2,_u8,,)(data, indices);
73 }
74 
test_svtbl2_u16(svuint16x2_t data,svuint16_t indices)75 svuint16_t test_svtbl2_u16(svuint16x2_t data, svuint16_t indices)
76 {
77   // CHECK-LABEL: test_svtbl2_u16
78   // CHECK-DAG: %[[V0:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.tuple.get.nxv8i16.nxv16i16(<vscale x 16 x i16> %data, i32 0)
79   // CHECK-DAG: %[[V1:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.tuple.get.nxv8i16.nxv16i16(<vscale x 16 x i16> %data, i32 1)
80   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.tbl2.nxv8i16(<vscale x 8 x i16> %[[V0]], <vscale x 8 x i16> %[[V1]], <vscale x 8 x i16> %indices)
81   // CHECK-NEXT: ret <vscale x 8 x i16> %[[INTRINSIC]]
82   // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
83   // expected-warning@+1 {{implicit declaration of function 'svtbl2_u16'}}
84   return SVE_ACLE_FUNC(svtbl2,_u16,,)(data, indices);
85 }
86 
test_svtbl2_u32(svuint32x2_t data,svuint32_t indices)87 svuint32_t test_svtbl2_u32(svuint32x2_t data, svuint32_t indices)
88 {
89   // CHECK-LABEL: test_svtbl2_u32
90   // CHECK-DAG: %[[V0:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.tuple.get.nxv4i32.nxv8i32(<vscale x 8 x i32> %data, i32 0)
91   // CHECK-DAG: %[[V1:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.tuple.get.nxv4i32.nxv8i32(<vscale x 8 x i32> %data, i32 1)
92   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.tbl2.nxv4i32(<vscale x 4 x i32> %[[V0]], <vscale x 4 x i32> %[[V1]], <vscale x 4 x i32> %indices)
93   // CHECK-NEXT: ret <vscale x 4 x i32> %[[INTRINSIC]]
94   // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
95   // expected-warning@+1 {{implicit declaration of function 'svtbl2_u32'}}
96   return SVE_ACLE_FUNC(svtbl2,_u32,,)(data, indices);
97 }
98 
test_svtbl2_u64(svuint64x2_t data,svuint64_t indices)99 svuint64_t test_svtbl2_u64(svuint64x2_t data, svuint64_t indices)
100 {
101   // CHECK-LABEL: test_svtbl2_u64
102   // CHECK-DAG: %[[V0:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.tuple.get.nxv2i64.nxv4i64(<vscale x 4 x i64> %data, i32 0)
103   // CHECK-DAG: %[[V1:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.tuple.get.nxv2i64.nxv4i64(<vscale x 4 x i64> %data, i32 1)
104   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.tbl2.nxv2i64(<vscale x 2 x i64> %[[V0]], <vscale x 2 x i64> %[[V1]], <vscale x 2 x i64> %indices)
105   // CHECK-NEXT: ret <vscale x 2 x i64> %[[INTRINSIC]]
106   // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
107   // expected-warning@+1 {{implicit declaration of function 'svtbl2_u64'}}
108   return SVE_ACLE_FUNC(svtbl2,_u64,,)(data, indices);
109 }
110 
test_svtbl2_f16(svfloat16x2_t data,svuint16_t indices)111 svfloat16_t test_svtbl2_f16(svfloat16x2_t data, svuint16_t indices)
112 {
113   // CHECK-LABEL: test_svtbl2_f16
114   // CHECK-DAG: %[[V0:.*]] = call <vscale x 8 x half> @llvm.aarch64.sve.tuple.get.nxv8f16.nxv16f16(<vscale x 16 x half> %data, i32 0)
115   // CHECK-DAG: %[[V1:.*]] = call <vscale x 8 x half> @llvm.aarch64.sve.tuple.get.nxv8f16.nxv16f16(<vscale x 16 x half> %data, i32 1)
116   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x half> @llvm.aarch64.sve.tbl2.nxv8f16(<vscale x 8 x half> %[[V0]], <vscale x 8 x half> %[[V1]], <vscale x 8 x i16> %indices)
117   // CHECK-NEXT: ret <vscale x 8 x half> %[[INTRINSIC]]
118   // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
119   // expected-warning@+1 {{implicit declaration of function 'svtbl2_f16'}}
120   return SVE_ACLE_FUNC(svtbl2,_f16,,)(data, indices);
121 }
122 
test_svtbl2_f32(svfloat32x2_t data,svuint32_t indices)123 svfloat32_t test_svtbl2_f32(svfloat32x2_t data, svuint32_t indices)
124 {
125   // CHECK-LABEL: test_svtbl2_f32
126   // CHECK-DAG: %[[V0:.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.tuple.get.nxv4f32.nxv8f32(<vscale x 8 x float> %data, i32 0)
127   // CHECK-DAG: %[[V1:.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.tuple.get.nxv4f32.nxv8f32(<vscale x 8 x float> %data, i32 1)
128   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.tbl2.nxv4f32(<vscale x 4 x float> %[[V0]], <vscale x 4 x float> %[[V1]], <vscale x 4 x i32> %indices)
129   // CHECK-NEXT: ret <vscale x 4 x float> %[[INTRINSIC]]
130   // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
131   // expected-warning@+1 {{implicit declaration of function 'svtbl2_f32'}}
132   return SVE_ACLE_FUNC(svtbl2,_f32,,)(data, indices);
133 }
134 
test_svtbl2_f64(svfloat64x2_t data,svuint64_t indices)135 svfloat64_t test_svtbl2_f64(svfloat64x2_t data, svuint64_t indices)
136 {
137   // CHECK-LABEL: test_svtbl2_f64
138   // CHECK-DAG: %[[V0:.*]] = call <vscale x 2 x double> @llvm.aarch64.sve.tuple.get.nxv2f64.nxv4f64(<vscale x 4 x double> %data, i32 0)
139   // CHECK-DAG: %[[V1:.*]] = call <vscale x 2 x double> @llvm.aarch64.sve.tuple.get.nxv2f64.nxv4f64(<vscale x 4 x double> %data, i32 1)
140   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x double> @llvm.aarch64.sve.tbl2.nxv2f64(<vscale x 2 x double> %[[V0]], <vscale x 2 x double> %[[V1]], <vscale x 2 x i64> %indices)
141   // CHECK-NEXT: ret <vscale x 2 x double> %[[INTRINSIC]]
142   // overload-warning@+2 {{implicit declaration of function 'svtbl2'}}
143   // expected-warning@+1 {{implicit declaration of function 'svtbl2_f64'}}
144   return SVE_ACLE_FUNC(svtbl2,_f64,,)(data, indices);
145 }
146