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 (float *dst, float *src1, int *ind, float *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,) s1, s2, res1, res2, res3; 32 UNION_TYPE (AVX512F_LEN, i_d) ind; 33 float res_ref[SIZE]; 34 35 MASK_TYPE mask = MASK_VALUE; 36 37 for (i = 0; i < SIZE; i++) 38 { 39 ind.a[i] = 17 * (i << 1); 40 s1.a[i] = DEFAULT_VALUE; 41 s2.a[i] = 22.5 * i; 42 43 res1.a[i] = DEFAULT_VALUE; 44 res2.a[i] = DEFAULT_VALUE; 45 res3.a[i] = DEFAULT_VALUE; 46 } 47 48 CALC (res_ref, s1.a, ind.a, s2.a); 49 50 res1.x = INTRINSIC (_permutex2var_ps) (s1.x, ind.x, s2.x); 51 res2.x = INTRINSIC (_mask_permutex2var_ps) (s1.x, mask, ind.x, s2.x); 52 res3.x = 53 INTRINSIC (_maskz_permutex2var_ps) (mask, s1.x, ind.x, s2.x); 54 55 if (UNION_CHECK (AVX512F_LEN,) (res1, res_ref)) 56 abort (); 57 58 MASK_MERGE ()(res_ref, mask, SIZE); 59 if (UNION_CHECK (AVX512F_LEN,) (res2, res_ref)) 60 abort (); 61 62 MASK_ZERO ()(res_ref, mask, SIZE); 63 if (UNION_CHECK (AVX512F_LEN,) (res3, res_ref)) 64 abort (); 65} 66