1 // REQUIRES: aarch64-registered-target
2 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
3 // RUN: %clang_cc1 -DSVE_OVERLOADED_FORMS -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
4 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null 2>%t
5 // RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
6
7 // If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it.
8 // ASM-NOT: warning
9 #include <arm_sve.h>
10
11 #ifdef SVE_OVERLOADED_FORMS
12 // A simple used,unused... macro, long enough to represent any SVE builtin.
13 #define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
14 #else
15 #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
16 #endif
17
test_svtbl_s8(svint8_t data,svuint8_t indices)18 svint8_t test_svtbl_s8(svint8_t data, svuint8_t indices)
19 {
20 // CHECK-LABEL: test_svtbl_s8
21 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.tbl.nxv16i8(<vscale x 16 x i8> %data, <vscale x 16 x i8> %indices)
22 // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
23 return SVE_ACLE_FUNC(svtbl,_s8,,)(data, indices);
24 }
25
test_svtbl_s16(svint16_t data,svuint16_t indices)26 svint16_t test_svtbl_s16(svint16_t data, svuint16_t indices)
27 {
28 // CHECK-LABEL: test_svtbl_s16
29 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.tbl.nxv8i16(<vscale x 8 x i16> %data, <vscale x 8 x i16> %indices)
30 // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
31 return SVE_ACLE_FUNC(svtbl,_s16,,)(data, indices);
32 }
33
test_svtbl_s32(svint32_t data,svuint32_t indices)34 svint32_t test_svtbl_s32(svint32_t data, svuint32_t indices)
35 {
36 // CHECK-LABEL: test_svtbl_s32
37 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.tbl.nxv4i32(<vscale x 4 x i32> %data, <vscale x 4 x i32> %indices)
38 // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
39 return SVE_ACLE_FUNC(svtbl,_s32,,)(data, indices);
40 }
41
test_svtbl_s64(svint64_t data,svuint64_t indices)42 svint64_t test_svtbl_s64(svint64_t data, svuint64_t indices)
43 {
44 // CHECK-LABEL: test_svtbl_s64
45 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.tbl.nxv2i64(<vscale x 2 x i64> %data, <vscale x 2 x i64> %indices)
46 // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
47 return SVE_ACLE_FUNC(svtbl,_s64,,)(data, indices);
48 }
49
test_svtbl_u8(svuint8_t data,svuint8_t indices)50 svuint8_t test_svtbl_u8(svuint8_t data, svuint8_t indices)
51 {
52 // CHECK-LABEL: test_svtbl_u8
53 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.tbl.nxv16i8(<vscale x 16 x i8> %data, <vscale x 16 x i8> %indices)
54 // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
55 return SVE_ACLE_FUNC(svtbl,_u8,,)(data, indices);
56 }
57
test_svtbl_u16(svuint16_t data,svuint16_t indices)58 svuint16_t test_svtbl_u16(svuint16_t data, svuint16_t indices)
59 {
60 // CHECK-LABEL: test_svtbl_u16
61 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.tbl.nxv8i16(<vscale x 8 x i16> %data, <vscale x 8 x i16> %indices)
62 // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
63 return SVE_ACLE_FUNC(svtbl,_u16,,)(data, indices);
64 }
65
test_svtbl_u32(svuint32_t data,svuint32_t indices)66 svuint32_t test_svtbl_u32(svuint32_t data, svuint32_t indices)
67 {
68 // CHECK-LABEL: test_svtbl_u32
69 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.tbl.nxv4i32(<vscale x 4 x i32> %data, <vscale x 4 x i32> %indices)
70 // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
71 return SVE_ACLE_FUNC(svtbl,_u32,,)(data, indices);
72 }
73
test_svtbl_u64(svuint64_t data,svuint64_t indices)74 svuint64_t test_svtbl_u64(svuint64_t data, svuint64_t indices)
75 {
76 // CHECK-LABEL: test_svtbl_u64
77 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.tbl.nxv2i64(<vscale x 2 x i64> %data, <vscale x 2 x i64> %indices)
78 // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
79 return SVE_ACLE_FUNC(svtbl,_u64,,)(data, indices);
80 }
81
test_svtbl_f16(svfloat16_t data,svuint16_t indices)82 svfloat16_t test_svtbl_f16(svfloat16_t data, svuint16_t indices)
83 {
84 // CHECK-LABEL: test_svtbl_f16
85 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x half> @llvm.aarch64.sve.tbl.nxv8f16(<vscale x 8 x half> %data, <vscale x 8 x i16> %indices)
86 // CHECK: ret <vscale x 8 x half> %[[INTRINSIC]]
87 return SVE_ACLE_FUNC(svtbl,_f16,,)(data, indices);
88 }
89
test_svtbl_f32(svfloat32_t data,svuint32_t indices)90 svfloat32_t test_svtbl_f32(svfloat32_t data, svuint32_t indices)
91 {
92 // CHECK-LABEL: test_svtbl_f32
93 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.tbl.nxv4f32(<vscale x 4 x float> %data, <vscale x 4 x i32> %indices)
94 // CHECK: ret <vscale x 4 x float> %[[INTRINSIC]]
95 return SVE_ACLE_FUNC(svtbl,_f32,,)(data, indices);
96 }
97
test_svtbl_f64(svfloat64_t data,svuint64_t indices)98 svfloat64_t test_svtbl_f64(svfloat64_t data, svuint64_t indices)
99 {
100 // CHECK-LABEL: test_svtbl_f64
101 // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x double> @llvm.aarch64.sve.tbl.nxv2f64(<vscale x 2 x double> %data, <vscale x 2 x i64> %indices)
102 // CHECK: ret <vscale x 2 x double> %[[INTRINSIC]]
103 return SVE_ACLE_FUNC(svtbl,_f64,,)(data, indices);
104 }
105