1  /* { dg-do run } */
       2  /* { dg-options "-mavx2 -O2" } */
       3  /* { dg-require-effective-target avx2 } */
       4  
       5  #include "avx2-check.h"
       6  #include <string.h>
       7  
       8  #define NUM 10
       9  
      10  static void
      11  init_pbroadcastb256 (char *src, int seed)
      12  {
      13    int i, sign = 1;
      14  
      15    for (i = 0; i < 16; i++)
      16      {
      17        src[i] = (i + seed) * (i + seed) * sign;
      18        sign = -sign;
      19      }
      20  }
      21  
      22  static void
      23  calc_pbroadcastb256 (char *src, char *dst)
      24  {
      25    int i;
      26  
      27    for (i = 0; i < 32; i++)
      28      dst[i] = src[0];
      29  }
      30  
      31  static void
      32  avx2_test (void)
      33  {
      34    union128i_b src;
      35    union256i_b dst;
      36    char dst_ref[32];
      37    int i;
      38  
      39    for (i = 0; i < NUM; i++)
      40      {
      41        init_pbroadcastb256 (src.a, i);
      42  
      43        dst.x = _mm256_broadcastb_epi8 (src.x);
      44        calc_pbroadcastb256 (src.a, dst_ref);
      45  
      46        if (check_union256i_b (dst, dst_ref))
      47  	abort ();
      48      }
      49  }