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