PR c++/67273
[official-gcc.git] / gcc / testsuite / gcc.target / arm / attr-fp16-arith-1.c
bloba93d30f85a61286dcaf4a66c1074b5795ef3f0c7
1 /* { dg-do compile } */
2 /* { dg-require-effective-target arm_v8_2a_fp16_neon_ok } */
3 /* { dg-options "-O2" } */
4 /* { dg-add-options arm_v8_2a_fp16_scalar } */
6 /* Reset fpu to a value compatible with the next pragmas. */
7 #pragma GCC target ("fpu=vfp")
9 #pragma GCC push_options
10 #pragma GCC target ("fpu=fp-armv8")
12 #ifndef __ARM_FEATURE_FP16_SCALAR_ARITHMETIC
13 #error __ARM_FEATURE_FP16_SCALAR_ARITHMETIC not defined.
14 #endif
16 #pragma GCC push_options
17 #pragma GCC target ("fpu=neon-fp-armv8")
19 #ifndef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
20 #error __ARM_FEATURE_FP16_VECTOR_ARITHMETIC not defined.
21 #endif
23 #ifndef __ARM_NEON
24 #error __ARM_NEON not defined.
25 #endif
27 #if !defined (__ARM_FP) || !(__ARM_FP & 0x2)
28 #error Invalid value for __ARM_FP
29 #endif
31 #include "arm_neon.h"
33 float16_t
34 foo (float16x4_t b)
36 float16x4_t a = {2.0, 3.0, 4.0, 5.0};
37 float16x4_t res = vadd_f16 (a, b);
39 return res[0];
42 /* { dg-final { scan-assembler "vadd\\.f16\td\[0-9\]+, d\[0-9\]+" } } */
44 #pragma GCC pop_options
46 /* Check that the FP version is correctly reset to mfpu=fp-armv8. */
48 #if !defined (__ARM_FP) || !(__ARM_FP & 0x2)
49 #error __ARM_FP should record FP16 support.
50 #endif
52 #pragma GCC pop_options
54 /* Check that the FP version is correctly reset to mfpu=vfp. */
56 #if !defined (__ARM_FP) || (__ARM_FP & 0x2)
57 #error Unexpected value for __ARM_FP.
58 #endif