155682Smarkm/* { dg-do run } */ 2233294Sstas/* { dg-require-effective-target avx2 } */ 3233294Sstas/* { dg-options "-O2 -mavx2" } */ 4233294Sstas 555682Smarkm#include <string.h> 6233294Sstas#include "avx2-check.h" 7233294Sstas 8233294Sstasstatic void 955682Smarkmcompute_i64gatherpd256 (double *s1, long long int *s2, int scale, double *r) 10233294Sstas{ 11233294Sstas int i; 1255682Smarkm 13233294Sstas for (i = 0; i < 4; ++i) 14233294Sstas r[i] = *(double *) (((unsigned char *) s1) + s2[i] * scale); 15233294Sstas} 1655682Smarkm 17233294Sstasvoid static 18233294Sstasavx2_test (void) 19233294Sstas{ 2055682Smarkm int i; 21233294Sstas union256i_q idx; 22233294Sstas union256d res; 23233294Sstas double s1[4], res_ref[4] = { 0 }; 24233294Sstas 25233294Sstas for (i = 0; i < 4; ++i) 26233294Sstas { 27233294Sstas /* Set some stuff */ 28233294Sstas s1[i] = 2.718281828459045 * (i + 1) * (i + 2); 29233294Sstas 30233294Sstas /* About to gather in reverse order, 31233294Sstas divide by 2 to demonstrate scale */ 3255682Smarkm idx.a[i] = (32 - (i + 1) * 8) >> 1; 3355682Smarkm } 3455682Smarkm 35178825Sdfr res.x = _mm256_i64gather_pd (s1, idx.x, 2); 3655682Smarkm 3755682Smarkm compute_i64gatherpd256 (s1, idx.a, 2, res_ref); 38178825Sdfr 39178825Sdfr if (check_union256d (res, res_ref) != 0) 4055682Smarkm abort (); 41178825Sdfr} 4255682Smarkm