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 17void 18CALC (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 31void 32TEST (void) 33{ 34 int i, j; 35 UNION_TYPE (AVX512F_LEN, i_b) s1, s2, res, 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] = DEFAULT_VALUE; 45 s1.a[j] = i * 2 * j + 1; 46 s2.a[j] = i * 2 * j; 47 48 res.a[j] = DEFAULT_VALUE; 49 } 50 51 CALC (res_ref, s1.a, ind.a, s2.a); 52 53 res.x = 54 INTRINSIC (_mask2_permutex2var_epi8) (s1.x, ind.x, mask, 55 s2.x); 56 57 MASK_MERGE (i_b) (res_ref, mask, SIZE); 58 if (UNION_CHECK (AVX512F_LEN, i_b) (res, res_ref)) 59 abort (); 60 } 61} 62