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#include "math.h" 12 13static void 14CALC (int *dst, int *src1, int *ind, int *src2) 15{ 16 int i; 17 18 for (i = 0; i < SIZE; i++) 19 { 20 unsigned long long offset = ind[i] & (SIZE - 1); 21 unsigned long long cond = ind[i] & SIZE; 22 23 dst[i] = cond ? src2[offset] : src1[offset]; 24 } 25} 26 27void 28TEST (void) 29{ 30 int i; 31 UNION_TYPE (AVX512F_LEN, i_d) s1, s2, res1, res2, res3, ind; 32 int res_ref[SIZE]; 33 34 MASK_TYPE mask = MASK_VALUE; 35 36 for (i = 0; i < SIZE; i++) 37 { 38 ind.a[i] = 17 * (i << 1); 39 s1.a[i] = DEFAULT_VALUE; 40 s2.a[i] = 34 * i; 41 42 res1.a[i] = DEFAULT_VALUE; 43 res2.a[i] = DEFAULT_VALUE; 44 res3.a[i] = DEFAULT_VALUE; 45 } 46 47 CALC (res_ref, s1.a, ind.a, s2.a); 48 49 res1.x = INTRINSIC (_permutex2var_epi32) (s1.x, ind.x, s2.x); 50 res2.x = 51 INTRINSIC (_mask_permutex2var_epi32) (s1.x, mask, ind.x, s2.x); 52 res3.x = 53 INTRINSIC (_maskz_permutex2var_epi32) (mask, s1.x, ind.x, s2.x); 54 55 if (UNION_CHECK (AVX512F_LEN, i_d) (res1, res_ref)) 56 abort (); 57 58 MASK_MERGE (i_d) (res_ref, mask, SIZE); 59 if (UNION_CHECK (AVX512F_LEN, i_d) (res2, res_ref)) 60 abort (); 61 62 MASK_ZERO (i_d) (res_ref, mask, SIZE); 63 if (UNION_CHECK (AVX512F_LEN, i_d) (res3, res_ref)) 64 abort (); 65} 66