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 } */
       5  
       6  /* Reset fpu to a value compatible with the next pragmas.  */
       7  #pragma GCC target ("fpu=vfp")
       8  
       9  #pragma GCC push_options
      10  #pragma GCC target ("fpu=fp-armv8")
      11  
      12  #ifndef __ARM_FEATURE_FP16_SCALAR_ARITHMETIC
      13  #error __ARM_FEATURE_FP16_SCALAR_ARITHMETIC not defined.
      14  #endif
      15  
      16  #pragma GCC push_options
      17  #pragma GCC target ("fpu=neon-fp-armv8")
      18  
      19  #ifndef __ARM_FEATURE_FP16_VECTOR_ARITHMETIC
      20  #error __ARM_FEATURE_FP16_VECTOR_ARITHMETIC not defined.
      21  #endif
      22  
      23  #ifndef __ARM_NEON
      24  #error __ARM_NEON not defined.
      25  #endif
      26  
      27  #if !defined (__ARM_FP) || !(__ARM_FP & 0x2)
      28  #error Invalid value for __ARM_FP
      29  #endif
      30  
      31  #include "arm_neon.h"
      32  
      33  float16_t
      34  foo (float16x4_t b)
      35  {
      36    float16x4_t a = {2.0, 3.0, 4.0, 5.0};
      37    float16x4_t res = vadd_f16 (a, b);
      38  
      39    return res[0];
      40  }
      41  
      42  /* { dg-final { scan-assembler "vadd\\.f16\td\[0-9\]+, d\[0-9\]+" } } */
      43  
      44  #pragma GCC pop_options
      45  
      46  /* Check that the FP version is correctly reset to mfpu=fp-armv8.  */
      47  
      48  #if !defined (__ARM_FP) || !(__ARM_FP & 0x2)
      49  #error __ARM_FP should record FP16 support.
      50  #endif
      51  
      52  #pragma GCC pop_options
      53  
      54  /* Check that the FP version is correctly reset to mfpu=vfp.  */
      55  
      56  #if !defined (__ARM_FP) || (__ARM_FP & 0x2)
      57  #error Unexpected value for __ARM_FP.
      58  #endif