1 // 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
2 // 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
3 
4 #include <arm_sve.h>
5 
6 #ifdef SVE_OVERLOADED_FORMS
7 // A simple used,unused... macro, long enough to represent any SVE builtin.
8 #define SVE_ACLE_FUNC(A1,A2_UNUSED,A3,A4_UNUSED) A1##A3
9 #else
10 #define SVE_ACLE_FUNC(A1,A2,A3,A4) A1##A2##A3##A4
11 #endif
12 
13 
14 // NOTE: For these tests clang converts the struct parameter into
15 // several parameters, one for each member of the original struct.
test_svset3_s8(svint8x3_t tuple,svint8_t x)16 svint8x3_t test_svset3_s8(svint8x3_t tuple, svint8_t x)
17 {
18   // CHECK-LABEL: test_svset3_s8
19   // CHECK: %[[INSERT:.*]] = call <vscale x 48 x i8> @llvm.aarch64.sve.tuple.set.nxv48i8.nxv16i8(<vscale x 48 x i8> %tuple, i32 1, <vscale x 16 x i8> %x)
20   // CHECK-NEXT: ret <vscale x 48 x i8> %[[INSERT]]
21   return SVE_ACLE_FUNC(svset3,_s8,,)(tuple, 1, x);
22 }
23 
test_svset3_s16(svint16x3_t tuple,svint16_t x)24 svint16x3_t test_svset3_s16(svint16x3_t tuple, svint16_t x)
25 {
26   // CHECK-LABEL: test_svset3_s16
27   // CHECK: %[[INSERT:.*]] = call <vscale x 24 x i16> @llvm.aarch64.sve.tuple.set.nxv24i16.nxv8i16(<vscale x 24 x i16> %tuple, i32 2, <vscale x 8 x i16> %x)
28   // CHECK-NEXT: ret <vscale x 24 x i16> %[[INSERT]]
29   return SVE_ACLE_FUNC(svset3,_s16,,)(tuple, 2, x);
30 }
31 
test_svset3_s32(svint32x3_t tuple,svint32_t x)32 svint32x3_t test_svset3_s32(svint32x3_t tuple, svint32_t x)
33 {
34   // CHECK-LABEL: test_svset3_s32
35   // CHECK: %[[INSERT:.*]] = call <vscale x 12 x i32> @llvm.aarch64.sve.tuple.set.nxv12i32.nxv4i32(<vscale x 12 x i32> %tuple, i32 0, <vscale x 4 x i32> %x)
36   // CHECK-NEXT: ret <vscale x 12 x i32> %[[INSERT]]
37   return SVE_ACLE_FUNC(svset3,_s32,,)(tuple, 0, x);
38 }
39 
test_svset3_s64(svint64x3_t tuple,svint64_t x)40 svint64x3_t test_svset3_s64(svint64x3_t tuple, svint64_t x)
41 {
42   // CHECK-LABEL: test_svset3_s64
43   // CHECK: %[[INSERT:.*]] = call <vscale x 6 x i64> @llvm.aarch64.sve.tuple.set.nxv6i64.nxv2i64(<vscale x 6 x i64> %tuple, i32 1, <vscale x 2 x i64> %x)
44   // CHECK-NEXT: ret <vscale x 6 x i64> %[[INSERT]]
45   return SVE_ACLE_FUNC(svset3,_s64,,)(tuple, 1, x);
46 }
47 
test_svset3_u8(svuint8x3_t tuple,svuint8_t x)48 svuint8x3_t test_svset3_u8(svuint8x3_t tuple, svuint8_t x)
49 {
50   // CHECK-LABEL: test_svset3_u8
51   // CHECK: %[[INSERT:.*]] = call <vscale x 48 x i8> @llvm.aarch64.sve.tuple.set.nxv48i8.nxv16i8(<vscale x 48 x i8> %tuple, i32 2, <vscale x 16 x i8> %x)
52   // CHECK-NEXT: ret <vscale x 48 x i8> %[[INSERT]]
53   return SVE_ACLE_FUNC(svset3,_u8,,)(tuple, 2, x);
54 }
55 
test_svset3_u16(svuint16x3_t tuple,svuint16_t x)56 svuint16x3_t test_svset3_u16(svuint16x3_t tuple, svuint16_t x)
57 {
58   // CHECK-LABEL: test_svset3_u16
59   // CHECK: %[[INSERT:.*]] = call <vscale x 24 x i16> @llvm.aarch64.sve.tuple.set.nxv24i16.nxv8i16(<vscale x 24 x i16> %tuple, i32 0, <vscale x 8 x i16> %x)
60   // CHECK-NEXT: ret <vscale x 24 x i16> %[[INSERT]]
61   return SVE_ACLE_FUNC(svset3,_u16,,)(tuple, 0, x);
62 }
63 
test_svset3_u32(svuint32x3_t tuple,svuint32_t x)64 svuint32x3_t test_svset3_u32(svuint32x3_t tuple, svuint32_t x)
65 {
66   // CHECK-LABEL: test_svset3_u32
67   // CHECK: %[[INSERT:.*]] = call <vscale x 12 x i32> @llvm.aarch64.sve.tuple.set.nxv12i32.nxv4i32(<vscale x 12 x i32> %tuple, i32 1, <vscale x 4 x i32> %x)
68   // CHECK-NEXT: ret <vscale x 12 x i32> %[[INSERT]]
69   return SVE_ACLE_FUNC(svset3,_u32,,)(tuple, 1, x);
70 }
71 
test_svset3_u64(svuint64x3_t tuple,svuint64_t x)72 svuint64x3_t test_svset3_u64(svuint64x3_t tuple, svuint64_t x)
73 {
74   // CHECK-LABEL: test_svset3_u64
75   // CHECK: %[[INSERT:.*]] = call <vscale x 6 x i64> @llvm.aarch64.sve.tuple.set.nxv6i64.nxv2i64(<vscale x 6 x i64> %tuple, i32 2, <vscale x 2 x i64> %x)
76   // CHECK-NEXT: ret <vscale x 6 x i64> %[[INSERT]]
77   return SVE_ACLE_FUNC(svset3,_u64,,)(tuple, 2, x);
78 }
79 
test_svset3_f16(svfloat16x3_t tuple,svfloat16_t x)80 svfloat16x3_t test_svset3_f16(svfloat16x3_t tuple, svfloat16_t x)
81 {
82   // CHECK-LABEL: test_svset3_f16
83   // CHECK: %[[INSERT:.*]] = call <vscale x 24 x half> @llvm.aarch64.sve.tuple.set.nxv24f16.nxv8f16(<vscale x 24 x half> %tuple, i32 0, <vscale x 8 x half> %x)
84   // CHECK-NEXT: ret <vscale x 24 x half> %[[INSERT]]
85   return SVE_ACLE_FUNC(svset3,_f16,,)(tuple, 0, x);
86 }
87 
test_svset3_f32(svfloat32x3_t tuple,svfloat32_t x)88 svfloat32x3_t test_svset3_f32(svfloat32x3_t tuple, svfloat32_t x)
89 {
90   // CHECK-LABEL: test_svset3_f32
91   // CHECK: %[[INSERT:.*]] = call <vscale x 12 x float> @llvm.aarch64.sve.tuple.set.nxv12f32.nxv4f32(<vscale x 12 x float> %tuple, i32 1, <vscale x 4 x float> %x)
92   // CHECK-NEXT: ret <vscale x 12 x float> %[[INSERT]]
93   return SVE_ACLE_FUNC(svset3,_f32,,)(tuple, 1, x);
94 }
95 
test_svset3_f64(svfloat64x3_t tuple,svfloat64_t x)96 svfloat64x3_t test_svset3_f64(svfloat64x3_t tuple, svfloat64_t x)
97 {
98   // CHECK-LABEL: test_svset3_f64
99   // CHECK: %[[INSERT:.*]] = call <vscale x 6 x double> @llvm.aarch64.sve.tuple.set.nxv6f64.nxv2f64(<vscale x 6 x double> %tuple, i32 2, <vscale x 2 x double> %x)
100   // CHECK-NEXT: ret <vscale x 6 x double> %[[INSERT]]
101   return SVE_ACLE_FUNC(svset3,_f64,,)(tuple, 2, x);
102 }
103