1  /* { dg-do run } */
       2  /* { dg-require-effective-target avx2 } */
       3  /* { dg-options "-O2 -mavx2" } */
       4  
       5  
       6  #ifndef CHECK
       7  #define CHECK "avx2-check.h"
       8  #endif
       9  
      10  #ifndef TEST
      11  #define TEST avx2_test
      12  #endif
      13  
      14  #include CHECK
      15  
      16  #include "avx2-vec-set-1.c"
      17  
      18  #define CALC_TEST(vtype, type, N, idx)				\
      19  do								\
      20    {								\
      21      int i,val = idx * idx - idx * 3 + 16;			\
      22      type res[N],exp[N];						\
      23      vtype resv;							\
      24      for (i = 0; i < N; i++)					\
      25        {								\
      26  	res[i] = i * i - i * 3 + 15;				\
      27  	exp[i] = res[i];					\
      28        }								\
      29      exp[idx] = val;						\
      30      resv = foo_##vtype (*(vtype *)&res[0], val, idx);		\
      31      for (i = 0; i < N; i++)					\
      32        {								\
      33  	if (resv[i] != exp[i])					\
      34  	  abort ();						\
      35        }								\
      36    }								\
      37  while (0)
      38  
      39  static void
      40  TEST (void)
      41  {
      42    CALC_TEST (v32qi, char, 32, 17);
      43    CALC_TEST (v16qi, char, 16, 5);
      44    CALC_TEST (v16hi, short, 16, 9);
      45    CALC_TEST (v8hi, short, 8, 6);
      46    CALC_TEST (v8si, int, 8, 3);
      47    CALC_TEST (v4si, int, 4, 2);
      48    CALC_TEST (v4di, long long, 4, 1);
      49    CALC_TEST (v2di, long long, 2, 0);
      50  }