1  /* { dg-do run { target avx512fp16 } } */
       2  /* { dg-options "-O2 -mavx512fp16" } */
       3  
       4  #include <string.h>
       5  
       6  static void do_test (void);
       7  
       8  #define DO_TEST do_test
       9  #define AVX512FP16
      10  #include "avx512-check.h"
      11  
      12  void
      13  __attribute__ ((noinline, noclone))
      14  foo128 (_Float16 *p, __m128h x)
      15  {
      16    *p = ((__v8hf)x)[4];
      17  }
      18  
      19  void
      20  __attribute__ ((noinline, noclone))
      21  foo256 (_Float16 *p, __m256h x)
      22  {
      23    *p = ((__v16hf)x)[10];
      24  }
      25  
      26  void
      27  __attribute__ ((noinline, noclone))
      28  foo512 (_Float16 *p, __m512h x)
      29  {
      30    *p = ((__v32hf)x)[30];
      31  }
      32  
      33  static void
      34  do_test (void)
      35  {
      36    _Float16 x = 25.3;
      37    union128h u128 = { 0.0f, x, 0.0f, 0.0f, x, 0.0f, 0.0f, x };
      38    union256h u256 = { x, 0.0f, 0.0f, 0.0f, x, 0.0f, 0.0f, 0.0f,
      39  		     0.0f, 0.0f, x, 0.0f, 0.0f, x, 0.0f, 0.0f };
      40    union512h u512 = { x, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
      41  		     0.0f, x, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
      42  		     0.0f, 0.0f, x, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f,
      43  		     0.0f, 0.0f, 0.0f, x, 0.0f, 0.0f, x, 0.0f };
      44    __m128h v128 = _mm_setr_ph (0.0f, x, 0.0f, 0.0f,
      45  			      x, 0.0f, 0.0f, x);
      46    __m256h v256 = _mm256_setr_ph (x, 0.0f, 0.0f, 0.0f,
      47  				 x, 0.0f, 0.0f, 0.0f,
      48  				 0.0f, 0.0f, x, 0.0f,
      49  				 0.0f, x, 0.0f, 0.0f);
      50    __m512h v512 = _mm512_setr_ph (x, 0.0f, 0.0f, 0.0f,
      51  				 0.0f, 0.0f, 0.0f, 0.0f,
      52  				 0.0f, x, 0.0f, 0.0f,
      53  				 0.0f, 0.0f, 0.0f, 0.0f,
      54  				 0.0f, 0.0f, x, 0.0f,
      55  				 0.0f, 0.0f, 0.0f, 0.0f,
      56  				 0.0f, 0.0f, 0.0f, x,
      57  				 0.0f, 0.0f, x, 0.0f);
      58    union128h a128;
      59    union256h a256;
      60    union512h a512;
      61    _Float16 y;
      62  
      63    a128.x = v128;
      64    if (check_union128h (a128, u128.a))
      65      abort ();
      66  
      67    a256.x = v256;
      68    if (check_union256h (a256, u256.a))
      69      abort ();
      70  
      71    a512.x = v512;
      72    if (check_union512h (a512, u512.a))
      73      abort ();
      74  
      75    foo128 (&y, u128.x);
      76    if (x != y)
      77      abort ();
      78  
      79    foo256 (&y, u256.x);
      80    if (x != y)
      81      abort ();
      82  
      83    foo512 (&y, u512.x);
      84    if (x != y)
      85      abort ();
      86  }