aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/i386/avx2-vpbroadcastb256-2.c
blob: 9b0e5646973e1cfe4111fb468993679f468e2f4e (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
/* { dg-do run } */
/* { dg-options "-mavx2 -O2" } */
/* { dg-require-effective-target avx2 } */

#include "avx2-check.h"
#include <string.h>

#define NUM 10

static void
init_pbroadcastb256 (char *src, int seed)
{
  int i, sign = 1;

  for (i = 0; i < 16; i++)
    {
      src[i] = (i + seed) * (i + seed) * sign;
      sign = -sign;
    }
}

static void
calc_pbroadcastb256 (char *src, char *dst)
{
  int i;

  for (i = 0; i < 32; i++)
    dst[i] = src[0];
}

static void
avx2_test (void)
{
  union128i_b src;
  union256i_b dst;
  char dst_ref[32];
  int i;

  for (i = 0; i < NUM; i++)
    {
      init_pbroadcastb256 (src.a, i);

      dst.x = _mm256_broadcastb_epi8 (src.x);
      calc_pbroadcastb256 (src.a, dst_ref);

      if (check_union256i_b (dst, dst_ref))
	abort ();
    }
}