1 /* { dg-do run } */ 2 /* { dg-require-effective-target avx2 } */ 3 /* { dg-options "-O2 -mavx2" } */ 4 5 #include "ssse3-vals.h" 6 #include "avx2-check.h" 7 8 /* Routine to manually compute the results */ 9 static void compute_pabs256(int * i1,int * r)10compute_pabs256 (int *i1, int *r) 11 { 12 int i; 13 14 for (i = 0; i < 8; i++) 15 if (i1[i] < 0) 16 r[i] = -i1[i]; 17 else 18 r[i] = i1[i]; 19 } 20 21 static void avx2_test(void)22avx2_test (void) 23 { 24 int i; 25 int ck[8]; 26 int fail = 0; 27 28 union256i_d s, d; 29 30 for (i = 0; i < 256; ++i) 31 { 32 /* Recompute the results for 256-bits */ 33 compute_pabs256 (&vals[i], ck); 34 35 s.x = _mm256_loadu_si256 ((__m256i *) & vals[i]); 36 37 /* Run the 256-bit tests */ 38 d.x = _mm256_abs_epi32 (s.x); 39 40 fail += check_union256i_d (d, ck); 41 } 42 43 if (fail != 0) 44 abort (); 45 } 46