1  /* { dg-do run } */
       2  /* { dg-options "-O2 -mavx512vl -mprefer-vector-width=256" } */
       3  /* { dg-require-effective-target avx512vl } */
       4  
       5  #define AVX512VL
       6  #ifndef CHECK
       7  #define CHECK "avx512f-helper.h"
       8  #endif
       9  
      10  #include CHECK
      11  
      12  #include "cond_op_shift_d-1.c"
      13  
      14  #define BINO2C(OPNAME, OP)			\
      15    void						\
      16    __attribute__ ((noipa,optimize ("O2")))	\
      17    foo_o2_##OPNAME##_const ()			\
      18    {						\
      19      for (int i = 0; i != NUM; i++)		\
      20        if (b[i] < c[i])				\
      21  	j[i] = d[i] OP 3;			\
      22        else					\
      23  	j[i] = MAX(d[i], e[i]);			\
      24    }
      25  
      26  #define BINO2V(OPNAME, OP)			\
      27    void						\
      28    __attribute__ ((noipa,optimize ("O2")))	\
      29    foo_o2_##OPNAME##_variable ()			\
      30    {						\
      31      for (int i = 0; i != NUM; i++)		\
      32        if (b[i] < c[i])				\
      33  	j[i] = d[i] OP e[i];			\
      34        else					\
      35  	j[i] = MAX(d[i], e[i]);			\
      36    }
      37  
      38  BINO2C (shl, <<);
      39  BINO2C (shr, >>);
      40  BINO2V (shl, <<);
      41  BINO2V (shr, >>);
      42  
      43  static void
      44  test_256 (void)
      45  {
      46    int sign = -1;
      47    for (int i = 0; i != NUM; i++)
      48      {
      49        a[i] = 0;
      50        d[i] = i * 2;
      51        e[i] = (i * i * 3 - i * 9 + 6)%8;
      52        b[i] = i * 83;
      53        c[i] = b[i] + sign;
      54        sign *= -1;
      55        j[i] = 1;
      56      }
      57    foo_shl_const ();
      58    foo_o2_shl_const ();
      59    for (int i = 0; i != NUM; i++)
      60      {
      61        if (a[i] != j[i])
      62  	abort ();
      63        a[i] = 0;
      64        b[i] = 1;
      65      }
      66  
      67    foo_shr_const ();
      68    foo_o2_shr_const ();
      69    for (int i = 0; i != NUM; i++)
      70      {
      71        if (a[i] != j[i])
      72    	abort ();
      73        a[i] = 0;
      74        j[i] = 1;
      75      }
      76  
      77    foo_shl_variable ();
      78    foo_o2_shl_variable ();
      79    for (int i = 0; i != NUM; i++)
      80      {
      81        if (a[i] != j[i])
      82  	abort ();
      83        a[i] = 0;
      84        b[i] = 1;
      85      }
      86  
      87    foo_shr_variable ();
      88    foo_o2_shr_variable ();
      89    for (int i = 0; i != NUM; i++)
      90      {
      91        if (a[i] != j[i])
      92    	abort ();
      93        a[i] = 0;
      94        j[i] = 1;
      95      }
      96  }
      97  
      98  static void
      99  test_128 ()
     100  {
     101    
     102  }