testcase: Add testcase for PR 117330 [PR117330]
[official-gcc.git] / gcc / testsuite / gcc.target / aarch64 / bfloat16_simd_2.c
blob3891dcfc900ab942bf29eb638d16660a194597e4
1 /* { dg-do assemble { target { aarch64*-*-* } } } */
2 /* { dg-require-effective-target arm_v8_2a_bf16_neon_ok } */
3 /* { dg-additional-options "-march=armv8.2-a -O3 --save-temps" } */
4 /* { dg-final { check-function-bodies "**" "" } } */
6 #include <arm_neon.h>
8 #pragma GCC push_options
9 #pragma GCC target ("+bf16")
12 **stacktest1:
13 ** sub sp, sp, #16
14 ** str h0, \[sp, 14\]
15 ** ldr h0, \[sp, 14\]
16 ** add sp, sp, 16
17 ** ret
19 bfloat16_t stacktest1 (bfloat16_t __a)
21 volatile bfloat16_t b = __a;
22 return b;
26 **stacktest2:
27 ** sub sp, sp, #16
28 ** str d0, \[sp, 8\]
29 ** ldr d0, \[sp, 8\]
30 ** add sp, sp, 16
31 ** ret
33 bfloat16x4_t stacktest2 (bfloat16x4_t __a)
35 volatile bfloat16x4_t b = __a;
36 return b;
40 **stacktest3:
41 ** sub sp, sp, #16
42 ** str q0, \[sp\]
43 ** ldr q0, \[sp\]
44 ** add sp, sp, 16
45 ** ret
47 bfloat16x8_t stacktest3 (bfloat16x8_t __a)
49 volatile bfloat16x8_t b = __a;
50 return b;
53 /* Test compilation of __attribute__ vectors of 8, 16, 32, etc. BFloats. */
54 typedef bfloat16_t v8bf __attribute__((vector_size(16)));
55 typedef bfloat16_t v16bf __attribute__((vector_size(32)));
56 typedef bfloat16_t v32bf __attribute__((vector_size(64)));
57 typedef bfloat16_t v64bf __attribute__((vector_size(128)));
58 typedef bfloat16_t v128bf __attribute__((vector_size(256)));
60 v8bf stacktest4 (v8bf __a)
62 volatile v8bf b = __a;
63 return b;
66 v16bf stacktest5 (v16bf __a)
68 volatile v16bf b = __a;
69 return b;
72 v32bf stacktest6 (v32bf __a)
74 volatile v32bf b = __a;
75 return b;
78 v64bf stacktest7 (v64bf __a)
80 volatile v64bf b = __a;
81 return b;
84 v128bf stacktest8 (v128bf __a)
86 volatile v128bf b = __a;
87 return b;
90 /* Test use of constant values to assign values to vectors. */
92 typedef bfloat16_t v2bf __attribute__((vector_size(4)));
93 v2bf c2 (void) { return (v2bf) 0x12345678; }
95 bfloat16x4_t c3 (void) { return (bfloat16x4_t) 0x1234567812345678; }
97 #pragma GCC pop_options