2015-12-10 Vladimir Makarov <vmakarov@redhat.com>
[official-gcc.git] / gcc / testsuite / gcc.target / i386 / avx2-vpsignd-2.c
blob14e61b014ee91f4f5fe49f6e477ee168f05d05b1
1 /* { dg-do run } */
2 /* { dg-require-effective-target avx2 } */
3 /* { dg-options "-O2 -mavx2" } */
5 #include <string.h>
6 #include "avx2-check.h"
8 static void
9 compute_psignd256 (int *s1, int *s2, int *r)
11 int i;
13 for (i = 0; i < 8; i++)
14 if (s2[i] < 0)
15 r[i] = -s1[i];
16 else if (s2[i] == 0)
17 r[i] = 0;
18 else
19 r[i] = s1[i];
22 void static
23 avx2_test (void)
25 union256i_d s1, s2, res;
26 int res_ref[8];
27 int i, j;
28 int fail = 0;
30 for (i = 0; i < 10; i++)
32 for (j = 0; j < 8; j++)
34 s1.a[j] = j * i;
35 s2.a[j] = j + 20;
38 res.x = _mm256_sign_epi32 (s1.x, s2.x);
39 compute_psignd256 (s1.a, s2.a, res_ref);
41 fail += check_union256i_d (res, res_ref);
44 if (fail != 0)
45 abort ();