(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
i386/
avx512f-vpermilpsi-2.c
       1  /* { dg-do run } */
       2  /* { dg-options "-O2 -mavx512f" } */
       3  /* { dg-require-effective-target avx512f } */
       4  
       5  #define AVX512F
       6  
       7  #include "avx512f-helper.h"
       8  
       9  #define SIZE (AVX512F_LEN / 32)
      10  #include "avx512f-mask-type.h"
      11  
      12  #ifndef CTRL
      13  #define CTRL 129
      14  #endif
      15  
      16  #ifndef SELECT4_DEFINED
      17  #define SELECT4_DEFINED
      18  static int
      19  select4 (int i, unsigned ctrl)
      20  {
      21    int res;
      22    switch (i % 4)
      23      {
      24      case 0:
      25        res = (CTRL & 0x03);
      26        break;
      27      case 1:
      28        res = ((CTRL & 0x0c) >> 2);
      29        break;
      30      case 2:
      31        res = ((CTRL & 0x30) >> 4);
      32        break;
      33      case 3:
      34        res = ((CTRL & 0xc0) >> 6);
      35        break;
      36      }
      37    return res;
      38  }
      39  #endif
      40  
      41  static void
      42  CALC (float *s, float *r)
      43  {
      44    int i;
      45  
      46    for (i = 0; i < SIZE; i++)
      47      {
      48        r[i] = s[(4 * (i / 4)) + select4 (i, CTRL)];
      49      }
      50  }
      51  
      52  void
      53  TEST (void)
      54  {
      55    UNION_TYPE (AVX512F_LEN,) s1, res1, res2, res3;
      56    MASK_TYPE mask = MASK_VALUE;
      57    float res_ref[SIZE];
      58    int i;
      59  
      60    for (i = 0; i < SIZE; i++)
      61      {
      62        s1.a[i] = i + 10.;
      63        res2.a[i] = DEFAULT_VALUE;
      64      }
      65  
      66    res1.x = INTRINSIC (_permute_ps) (s1.x, CTRL);
      67    res2.x = INTRINSIC (_mask_permute_ps) (res2.x, mask, s1.x, CTRL);
      68    res3.x = INTRINSIC (_maskz_permute_ps) (mask, s1.x, CTRL);
      69  
      70    CALC (s1.a, res_ref);
      71  
      72    if (UNION_CHECK (AVX512F_LEN,) (res1, res_ref))
      73      abort ();
      74  
      75    MASK_MERGE ()(res_ref, mask, SIZE);
      76    if (UNION_CHECK (AVX512F_LEN,) (res2, res_ref))
      77      abort ();
      78  
      79    MASK_ZERO ()(res_ref, mask, SIZE);
      80    if (UNION_CHECK (AVX512F_LEN,) (res3, res_ref))
      81      abort ();
      82  }