(root)/
gcc-13.2.0/
gcc/
testsuite/
gcc.target/
i386/
avx512vbmi-vpermt2b-2.c
       1  /* { dg-do run } */
       2  /* { dg-options "-O2 -mavx512vbmi" } */
       3  /* { dg-require-effective-target avx512vbmi } */
       4  
       5  #define AVX512VBMI
       6  
       7  #include "avx512f-helper.h"
       8  
       9  #define SIZE (AVX512F_LEN / 8)
      10  #include <math.h>
      11  #include <limits.h>
      12  #include <float.h>
      13  #include "avx512f-mask-type.h"
      14  
      15  #define NUM 32
      16  
      17  void
      18  CALC (char *dst, char *src1, char *ind, char *src2)
      19  {
      20    int i;
      21  
      22    for (i = 0; i < SIZE; i++)
      23      {
      24        unsigned long long offset = ind[i] & (SIZE - 1);
      25        unsigned long long cond = ind[i] & SIZE;
      26  
      27        dst[i] = cond ? src2[offset] : src1[offset];
      28      }
      29  }
      30  
      31  void
      32  TEST (void)
      33  {
      34    int i, j;
      35    UNION_TYPE (AVX512F_LEN, i_b) s1, s2, res1, res2, res3, ind;
      36    char res_ref[SIZE];
      37  
      38    MASK_TYPE mask = MASK_VALUE;
      39  
      40    for (i = 0; i < NUM; i++)
      41      {
      42        for (j = 0; j < SIZE; j++)
      43  	{
      44  	  ind.a[j] = i * (j << 1);
      45  	  s1.a[j] = DEFAULT_VALUE;
      46  	  s2.a[j] = 1.5 * i * 2 * j;
      47  
      48  	  res1.a[j] = DEFAULT_VALUE;
      49  	  res2.a[j] = DEFAULT_VALUE;
      50  	  res3.a[j] = DEFAULT_VALUE;
      51  	}
      52  
      53        CALC (res_ref, s1.a, ind.a, s2.a);
      54  
      55        res1.x = INTRINSIC (_permutex2var_epi8) (s1.x, ind.x, s2.x);
      56        res2.x =
      57  	INTRINSIC (_mask_permutex2var_epi8) (s1.x, mask, ind.x, s2.x);
      58        res3.x =
      59  	INTRINSIC (_maskz_permutex2var_epi8) (mask, s1.x, ind.x,
      60  					       s2.x);
      61  
      62        if (UNION_CHECK (AVX512F_LEN, i_b) (res1, res_ref))
      63  	abort ();
      64  
      65        MASK_MERGE (i_b) (res_ref, mask, SIZE);
      66        if (UNION_CHECK (AVX512F_LEN, i_b) (res2, res_ref))
      67  	abort ();
      68  
      69        MASK_ZERO (i_b) (res_ref, mask, SIZE);
      70        if (UNION_CHECK (AVX512F_LEN, i_b) (res3, res_ref))
      71  	abort ();
      72      }
      73  }