1/* { dg-do run } */ 2/* { dg-options "-mavx512f -O2" } */ 3/* { dg-require-effective-target avx512f } */ 4 5#include "avx512f-check.h" 6 7#define SCALE 2 8 9static void 10compute_scatterqpd (__mmask8 m8, long long *idx, double *src, 11 int scale, double *r) 12{ 13 int i; 14 15 for (i = 0; i < 8; i++) 16 { 17 if (m8 & (1 << i)) 18 *(double *) (((unsigned char *) r) + idx[i] * scale) = src[i]; 19 } 20} 21 22static void 23avx512f_test (void) 24{ 25 int i; 26 union512d src; 27 union512i_q idx; 28 double res[8] = { 0.0 }; 29 double res_ref[8] = { 0.0 }; 30 __mmask8 m8 = 0xC5; 31 32 for (i = 0; i < 8; i++) 33 { 34 src.a[i] = 2.718281828459045 * (i + 1) * (i + 2); 35 36 /* About to gather in reverse order, 37 divide by 2 to demonstrate scale */ 38 idx.a[i] = (64 - (i + 1) * 8) >> 1; 39 } 40 41 _mm512_mask_i64scatter_pd (res, m8, idx.x, src.x, SCALE); 42 compute_scatterqpd (m8, idx.a, src.a, SCALE, res_ref); 43 44 if (checkVd (res, res_ref, 8)) 45 abort (); 46 47 _mm512_i64scatter_pd (res, idx.x, src.x, SCALE); 48 compute_scatterqpd (0xFF, idx.a, src.a, SCALE, res_ref); 49 50 if (checkVd (res, res_ref, 8)) 51 abort (); 52} 53