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 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - -x c++ %s | FileCheck %s
4 // 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
5 // 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 - -x c++ %s | FileCheck %s
6 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null
7 #include <arm_sve.h>
8 
9 #ifdef SVE_OVERLOADED_FORMS
10 // A simple used,unused... macro, long enough to represent any SVE builtin.
11 #define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
12 #else
13 #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
14 #endif
15 
test_svsplice_s8(svbool_t pg,svint8_t op1,svint8_t op2)16 svint8_t test_svsplice_s8(svbool_t pg, svint8_t op1, svint8_t op2)
17 {
18   // CHECK-LABEL: test_svsplice_s8
19   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.splice.nxv16i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %op1, <vscale x 16 x i8> %op2)
20   // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
21   return SVE_ACLE_FUNC(svsplice,_s8,,)(pg, op1, op2);
22 }
23 
test_svsplice_s16(svbool_t pg,svint16_t op1,svint16_t op2)24 svint16_t test_svsplice_s16(svbool_t pg, svint16_t op1, svint16_t op2)
25 {
26   // CHECK-LABEL: test_svsplice_s16
27   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
28   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.splice.nxv8i16(<vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op1, <vscale x 8 x i16> %op2)
29   // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
30   return SVE_ACLE_FUNC(svsplice,_s16,,)(pg, op1, op2);
31 }
32 
test_svsplice_s32(svbool_t pg,svint32_t op1,svint32_t op2)33 svint32_t test_svsplice_s32(svbool_t pg, svint32_t op1, svint32_t op2)
34 {
35   // CHECK-LABEL: test_svsplice_s32
36   // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
37   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.splice.nxv4i32(<vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op1, <vscale x 4 x i32> %op2)
38   // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
39   return SVE_ACLE_FUNC(svsplice,_s32,,)(pg, op1, op2);
40 }
41 
test_svsplice_s64(svbool_t pg,svint64_t op1,svint64_t op2)42 svint64_t test_svsplice_s64(svbool_t pg, svint64_t op1, svint64_t op2)
43 {
44   // CHECK-LABEL: test_svsplice_s64
45   // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
46   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.splice.nxv2i64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op1, <vscale x 2 x i64> %op2)
47   // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
48   return SVE_ACLE_FUNC(svsplice,_s64,,)(pg, op1, op2);
49 }
50 
test_svsplice_u8(svbool_t pg,svuint8_t op1,svuint8_t op2)51 svuint8_t test_svsplice_u8(svbool_t pg, svuint8_t op1, svuint8_t op2)
52 {
53   // CHECK-LABEL: test_svsplice_u8
54   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 16 x i8> @llvm.aarch64.sve.splice.nxv16i8(<vscale x 16 x i1> %pg, <vscale x 16 x i8> %op1, <vscale x 16 x i8> %op2)
55   // CHECK: ret <vscale x 16 x i8> %[[INTRINSIC]]
56   return SVE_ACLE_FUNC(svsplice,_u8,,)(pg, op1, op2);
57 }
58 
test_svsplice_u16(svbool_t pg,svuint16_t op1,svuint16_t op2)59 svuint16_t test_svsplice_u16(svbool_t pg, svuint16_t op1, svuint16_t op2)
60 {
61   // CHECK-LABEL: test_svsplice_u16
62   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
63   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x i16> @llvm.aarch64.sve.splice.nxv8i16(<vscale x 8 x i1> %[[PG]], <vscale x 8 x i16> %op1, <vscale x 8 x i16> %op2)
64   // CHECK: ret <vscale x 8 x i16> %[[INTRINSIC]]
65   return SVE_ACLE_FUNC(svsplice,_u16,,)(pg, op1, op2);
66 }
67 
test_svsplice_u32(svbool_t pg,svuint32_t op1,svuint32_t op2)68 svuint32_t test_svsplice_u32(svbool_t pg, svuint32_t op1, svuint32_t op2)
69 {
70   // CHECK-LABEL: test_svsplice_u32
71   // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
72   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x i32> @llvm.aarch64.sve.splice.nxv4i32(<vscale x 4 x i1> %[[PG]], <vscale x 4 x i32> %op1, <vscale x 4 x i32> %op2)
73   // CHECK: ret <vscale x 4 x i32> %[[INTRINSIC]]
74   return SVE_ACLE_FUNC(svsplice,_u32,,)(pg, op1, op2);
75 }
76 
test_svsplice_u64(svbool_t pg,svuint64_t op1,svuint64_t op2)77 svuint64_t test_svsplice_u64(svbool_t pg, svuint64_t op1, svuint64_t op2)
78 {
79   // CHECK-LABEL: test_svsplice_u64
80   // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
81   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x i64> @llvm.aarch64.sve.splice.nxv2i64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x i64> %op1, <vscale x 2 x i64> %op2)
82   // CHECK: ret <vscale x 2 x i64> %[[INTRINSIC]]
83   return SVE_ACLE_FUNC(svsplice,_u64,,)(pg, op1, op2);
84 }
85 
test_svsplice_f16(svbool_t pg,svfloat16_t op1,svfloat16_t op2)86 svfloat16_t test_svsplice_f16(svbool_t pg, svfloat16_t op1, svfloat16_t op2)
87 {
88   // CHECK-LABEL: test_svsplice_f16
89   // CHECK: %[[PG:.*]] = call <vscale x 8 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv8i1(<vscale x 16 x i1> %pg)
90   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 8 x half> @llvm.aarch64.sve.splice.nxv8f16(<vscale x 8 x i1> %[[PG]], <vscale x 8 x half> %op1, <vscale x 8 x half> %op2)
91   // CHECK: ret <vscale x 8 x half> %[[INTRINSIC]]
92   return SVE_ACLE_FUNC(svsplice,_f16,,)(pg, op1, op2);
93 }
94 
test_svsplice_f32(svbool_t pg,svfloat32_t op1,svfloat32_t op2)95 svfloat32_t test_svsplice_f32(svbool_t pg, svfloat32_t op1, svfloat32_t op2)
96 {
97   // CHECK-LABEL: test_svsplice_f32
98   // CHECK: %[[PG:.*]] = call <vscale x 4 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv4i1(<vscale x 16 x i1> %pg)
99   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 4 x float> @llvm.aarch64.sve.splice.nxv4f32(<vscale x 4 x i1> %[[PG]], <vscale x 4 x float> %op1, <vscale x 4 x float> %op2)
100   // CHECK: ret <vscale x 4 x float> %[[INTRINSIC]]
101   return SVE_ACLE_FUNC(svsplice,_f32,,)(pg, op1, op2);
102 }
103 
test_svsplice_f64(svbool_t pg,svfloat64_t op1,svfloat64_t op2)104 svfloat64_t test_svsplice_f64(svbool_t pg, svfloat64_t op1, svfloat64_t op2)
105 {
106   // CHECK-LABEL: test_svsplice_f64
107   // CHECK: %[[PG:.*]] = call <vscale x 2 x i1> @llvm.aarch64.sve.convert.from.svbool.nxv2i1(<vscale x 16 x i1> %pg)
108   // CHECK: %[[INTRINSIC:.*]] = call <vscale x 2 x double> @llvm.aarch64.sve.splice.nxv2f64(<vscale x 2 x i1> %[[PG]], <vscale x 2 x double> %op1, <vscale x 2 x double> %op2)
109   // CHECK: ret <vscale x 2 x double> %[[INTRINSIC]]
110   return SVE_ACLE_FUNC(svsplice,_f64,,)(pg, op1, op2);
111 }
112