1 // REQUIRES: aarch64-registered-target
2 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -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 -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -emit-llvm -o - %s | FileCheck %s
4
5 // RUN: %clang_cc1 -triple aarch64-none-linux-gnu -target-feature +sve -target-feature +bf16 -fallow-half-arguments-and-returns -S -O1 -Werror -Wall -o - %s >/dev/null 2>%t
6 // RUN: FileCheck --check-prefix=ASM --allow-empty %s <%t
7
8 // If this check fails please read test/CodeGen/aarch64-sve-intrinsics/README for instructions on how to resolve it.
9 // ASM-NOT: warning
10
11 #include <arm_sve.h>
12
13 #ifdef SVE_OVERLOADED_FORMS
14 // A simple used,unused... macro, long enough to represent any SVE builtin.
15 #define SVE_ACLE_FUNC(A1, A2_UNUSED, A3, A4_UNUSED) A1##A3
16 #else
17 #define SVE_ACLE_FUNC(A1, A2, A3, A4) A1##A2##A3##A4
18 #endif
19
test_svreinterpret_s8_bf16(svbfloat16_t op)20 svint8_t test_svreinterpret_s8_bf16(svbfloat16_t op) {
21 // CHECK-LABEL: test_svreinterpret_s8_bf16
22 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x bfloat> %op to <vscale x 16 x i8>
23 // CHECK: ret <vscale x 16 x i8> %[[CAST]]
24 return SVE_ACLE_FUNC(svreinterpret_s8, _bf16, , )(op);
25 }
26
test_svreinterpret_s16_bf16(svbfloat16_t op)27 svint16_t test_svreinterpret_s16_bf16(svbfloat16_t op) {
28 // CHECK-LABEL: test_svreinterpret_s16_bf16
29 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x bfloat> %op to <vscale x 8 x i16>
30 // CHECK: ret <vscale x 8 x i16> %[[CAST]]
31 return SVE_ACLE_FUNC(svreinterpret_s16, _bf16, , )(op);
32 }
33
test_svreinterpret_s32_bf16(svbfloat16_t op)34 svint32_t test_svreinterpret_s32_bf16(svbfloat16_t op) {
35 // CHECK-LABEL: test_svreinterpret_s32_bf16
36 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x bfloat> %op to <vscale x 4 x i32>
37 // CHECK: ret <vscale x 4 x i32> %[[CAST]]
38 return SVE_ACLE_FUNC(svreinterpret_s32, _bf16, , )(op);
39 }
test_svreinterpret_s64_bf16(svbfloat16_t op)40 svint64_t test_svreinterpret_s64_bf16(svbfloat16_t op) {
41 // CHECK-LABEL: test_svreinterpret_s64_bf16
42 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x bfloat> %op to <vscale x 2 x i64>
43 // CHECK: ret <vscale x 2 x i64> %[[CAST]]
44 return SVE_ACLE_FUNC(svreinterpret_s64, _bf16, , )(op);
45 }
46
test_svreinterpret_u8_bf16(svbfloat16_t op)47 svuint8_t test_svreinterpret_u8_bf16(svbfloat16_t op) {
48 // CHECK-LABEL: test_svreinterpret_u8_bf16
49 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x bfloat> %op to <vscale x 16 x i8>
50 // CHECK: ret <vscale x 16 x i8> %[[CAST]]
51 return SVE_ACLE_FUNC(svreinterpret_u8, _bf16, , )(op);
52 }
53
test_svreinterpret_u16_bf16(svbfloat16_t op)54 svuint16_t test_svreinterpret_u16_bf16(svbfloat16_t op) {
55 // CHECK-LABEL: test_svreinterpret_u16_bf16
56 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x bfloat> %op to <vscale x 8 x i16>
57 // CHECK: ret <vscale x 8 x i16> %[[CAST]]
58 return SVE_ACLE_FUNC(svreinterpret_u16, _bf16, , )(op);
59 }
60
test_svreinterpret_u32_bf16(svbfloat16_t op)61 svuint32_t test_svreinterpret_u32_bf16(svbfloat16_t op) {
62 // CHECK-LABEL: test_svreinterpret_u32_bf16
63 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x bfloat> %op to <vscale x 4 x i32>
64 // CHECK: ret <vscale x 4 x i32> %[[CAST]]
65 return SVE_ACLE_FUNC(svreinterpret_u32, _bf16, , )(op);
66 }
67
test_svreinterpret_u64_bf16(svbfloat16_t op)68 svuint64_t test_svreinterpret_u64_bf16(svbfloat16_t op) {
69 // CHECK-LABEL: test_svreinterpret_u64_bf16
70 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x bfloat> %op to <vscale x 2 x i64>
71 // CHECK: ret <vscale x 2 x i64> %[[CAST]]
72 return SVE_ACLE_FUNC(svreinterpret_u64, _bf16, , )(op);
73 }
74
test_svreinterpret_bf16_s8(svint8_t op)75 svbfloat16_t test_svreinterpret_bf16_s8(svint8_t op) {
76 // CHECK-LABEL: test_svreinterpret_bf16_s8
77 // CHECK: %[[CAST:.*]] = bitcast <vscale x 16 x i8> %op to <vscale x 8 x bfloat>
78 // CHECK: ret <vscale x 8 x bfloat> %[[CAST]]
79 return SVE_ACLE_FUNC(svreinterpret_bf16, _s8, , )(op);
80 }
81
test_svreinterpret_bf16_s16(svint16_t op)82 svbfloat16_t test_svreinterpret_bf16_s16(svint16_t op) {
83 // CHECK-LABEL: test_svreinterpret_bf16_s16
84 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x i16> %op to <vscale x 8 x bfloat>
85 // CHECK: ret <vscale x 8 x bfloat> %[[CAST]]
86 return SVE_ACLE_FUNC(svreinterpret_bf16, _s16, , )(op);
87 }
88
test_svreinterpret_bf16_s32(svint32_t op)89 svbfloat16_t test_svreinterpret_bf16_s32(svint32_t op) {
90 // CHECK-LABEL: test_svreinterpret_bf16_s32
91 // CHECK: %[[CAST:.*]] = bitcast <vscale x 4 x i32> %op to <vscale x 8 x bfloat>
92 // CHECK: ret <vscale x 8 x bfloat> %[[CAST]]
93 return SVE_ACLE_FUNC(svreinterpret_bf16, _s32, , )(op);
94 }
95
test_svreinterpret_bf16_s64(svint64_t op)96 svbfloat16_t test_svreinterpret_bf16_s64(svint64_t op) {
97 // CHECK-LABEL: test_svreinterpret_bf16_s64
98 // CHECK: %[[CAST:.*]] = bitcast <vscale x 2 x i64> %op to <vscale x 8 x bfloat>
99 // CHECK: ret <vscale x 8 x bfloat> %[[CAST]]
100 return SVE_ACLE_FUNC(svreinterpret_bf16, _s64, , )(op);
101 }
102
test_svreinterpret_bf16_u8(svuint8_t op)103 svbfloat16_t test_svreinterpret_bf16_u8(svuint8_t op) {
104 // CHECK-LABEL: test_svreinterpret_bf16_u8
105 // CHECK: %[[CAST:.*]] = bitcast <vscale x 16 x i8> %op to <vscale x 8 x bfloat>
106 // CHECK: ret <vscale x 8 x bfloat> %[[CAST]]
107 return SVE_ACLE_FUNC(svreinterpret_bf16, _u8, , )(op);
108 }
109
test_svreinterpret_bf16_u16(svuint16_t op)110 svbfloat16_t test_svreinterpret_bf16_u16(svuint16_t op) {
111 // CHECK-LABEL: test_svreinterpret_bf16_u16
112 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x i16> %op to <vscale x 8 x bfloat>
113 // CHECK: ret <vscale x 8 x bfloat> %[[CAST]]
114 return SVE_ACLE_FUNC(svreinterpret_bf16, _u16, , )(op);
115 }
116
test_svreinterpret_bf16_u32(svuint32_t op)117 svbfloat16_t test_svreinterpret_bf16_u32(svuint32_t op) {
118 // CHECK-LABEL: test_svreinterpret_bf16_u32
119 // CHECK: %[[CAST:.*]] = bitcast <vscale x 4 x i32> %op to <vscale x 8 x bfloat>
120 // CHECK: ret <vscale x 8 x bfloat> %[[CAST]]
121 return SVE_ACLE_FUNC(svreinterpret_bf16, _u32, , )(op);
122 }
123
test_svreinterpret_bf16_u64(svuint64_t op)124 svbfloat16_t test_svreinterpret_bf16_u64(svuint64_t op) {
125 // CHECK-LABEL: test_svreinterpret_bf16_u64
126 // CHECK: %[[CAST:.*]] = bitcast <vscale x 2 x i64> %op to <vscale x 8 x bfloat>
127 // CHECK: ret <vscale x 8 x bfloat> %[[CAST]]
128 return SVE_ACLE_FUNC(svreinterpret_bf16, _u64, , )(op);
129 }
130
test_svreinterpret_bf16_bf16(svbfloat16_t op)131 svbfloat16_t test_svreinterpret_bf16_bf16(svbfloat16_t op) {
132 // CHECK-LABEL: test_svreinterpret_bf16_bf16
133 // CHECK: ret <vscale x 8 x bfloat> %op
134 return SVE_ACLE_FUNC(svreinterpret_bf16, _bf16, , )(op);
135 }
136
test_svreinterpret_bf16_f16(svfloat16_t op)137 svbfloat16_t test_svreinterpret_bf16_f16(svfloat16_t op) {
138 // CHECK-LABEL: test_svreinterpret_bf16_f16
139 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x half> %op to <vscale x 8 x bfloat>
140 // CHECK: ret <vscale x 8 x bfloat> %[[CAST]]
141 return SVE_ACLE_FUNC(svreinterpret_bf16, _f16, , )(op);
142 }
143
test_svreinterpret_bf16_f32(svfloat32_t op)144 svbfloat16_t test_svreinterpret_bf16_f32(svfloat32_t op) {
145 // CHECK-LABEL: test_svreinterpret_bf16_f32
146 // CHECK: %[[CAST:.*]] = bitcast <vscale x 4 x float> %op to <vscale x 8 x bfloat>
147 // CHECK: ret <vscale x 8 x bfloat> %[[CAST]]
148 return SVE_ACLE_FUNC(svreinterpret_bf16, _f32, , )(op);
149 }
150
test_svreinterpret_bf16_f64(svfloat64_t op)151 svbfloat16_t test_svreinterpret_bf16_f64(svfloat64_t op) {
152 // CHECK-LABEL: test_svreinterpret_bf16_f64
153 // CHECK: %[[CAST:.*]] = bitcast <vscale x 2 x double> %op to <vscale x 8 x bfloat>
154 // CHECK: ret <vscale x 8 x bfloat> %[[CAST]]
155 return SVE_ACLE_FUNC(svreinterpret_bf16, _f64, , )(op);
156 }
157
test_svreinterpret_f32_bf16(svbfloat16_t op)158 svfloat32_t test_svreinterpret_f32_bf16(svbfloat16_t op) {
159 // CHECK-LABEL: test_svreinterpret_f32_bf16
160 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x bfloat> %op to <vscale x 4 x float>
161 // CHECK: ret <vscale x 4 x float> %[[CAST]]
162 return SVE_ACLE_FUNC(svreinterpret_f32, _bf16, , )(op);
163 }
164
test_svreinterpret_f16_bf16(svbfloat16_t op)165 svfloat16_t test_svreinterpret_f16_bf16(svbfloat16_t op) {
166 // CHECK-LABEL: test_svreinterpret_f16_bf16
167 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x bfloat> %op to <vscale x 8 x half>
168 // CHECK: ret <vscale x 8 x half> %[[CAST]]
169 return SVE_ACLE_FUNC(svreinterpret_f16, _bf16, , )(op);
170 }
171
test_svreinterpret_f64_bf16(svbfloat16_t op)172 svfloat64_t test_svreinterpret_f64_bf16(svbfloat16_t op) {
173 // CHECK-LABEL: test_svreinterpret_f64_bf16
174 // CHECK: %[[CAST:.*]] = bitcast <vscale x 8 x bfloat> %op to <vscale x 2 x double>
175 // CHECK: ret <vscale x 2 x double> %[[CAST]]
176 return SVE_ACLE_FUNC(svreinterpret_f64, _bf16, , )(op);
177 }
178