1/* { dg-do run } */
2/* { dg-options "-mavx2 -O2" } */
3/* { dg-require-effective-target avx2 } */
4
5#include "avx2-check.h"
6#include "ssse3-vals.h"
7
8static void
9compute_phaddd256 (int *i1, int *i2, int *r)
10{
11  int i;
12
13  for (i = 0; i < 2; i++)
14    r[i + 0] = i1[2 * i] + i1[2 * i + 1];
15
16  for (i = 0; i < 2; i++)
17    r[i + 2] = i2[2 * i] + i2[2 * i + 1];
18
19  for (i = 0; i < 2; i++)
20    r[i + 4] = i1[2 * i + 4] + i1[2 * i + 5];
21
22  for (i = 0; i < 2; i++)
23    r[i + 6] = i2[2 * i + 4] + i2[2 * i + 5];
24}
25
26static void
27avx2_test (void)
28{
29  union256i_d s1, s2, res;
30  int res_ref[8];
31  int i, j;
32  int fail = 0;
33
34
35  for (i = 0; i < 256; i += 16)
36    {
37      s1.x = _mm256_loadu_si256 ((__m256i *) & vals[i]);
38      s2.x = _mm256_loadu_si256 ((__m256i *) & vals[i + 8]);
39
40      res.x = _mm256_hadd_epi32 (s1.x, s2.x);
41
42      compute_phaddd256 (s1.a, s2.a, res_ref);
43
44      fail += check_union256i_d (res, res_ref);
45    }
46
47  if (fail != 0)
48    abort ();
49}
50