summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/avx512f-set-v8di-4.c
blob: ea6421fcc035d4bd103fdc180c38107a2a927010 (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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/* { dg-do run } */
/* { dg-options "-O2 -mavx512f" } */
/* { dg-require-effective-target avx512f } */

#include "avx512f-check.h"

static __m512i
__attribute__ ((noinline))
foo (long long x, int i)
{
  switch (i)
    {
    case 7:
      return _mm512_set_epi64 (x, 0, 0, 0, 0, 0, 0, 0);
    case 6:
      return _mm512_set_epi64 (0, x, 0, 0, 0, 0, 0, 0);
    case 5:
      return _mm512_set_epi64 (0, 0, x, 0, 0, 0, 0, 0);
    case 4:
      return _mm512_set_epi64 (0, 0, 0, x, 0, 0, 0, 0);
    case 3:
      return _mm512_set_epi64 (0, 0, 0, 0, x, 0, 0, 0);
    case 2:
      return _mm512_set_epi64 (0, 0, 0, 0, 0, x, 0, 0);
    case 1:
      return _mm512_set_epi64 (0, 0, 0, 0, 0, 0, x, 0);
    case 0:
      return _mm512_set_epi64 (0, 0, 0, 0, 0, 0, 0, x);
    default:
      abort ();
    }
}

static __m512i
__attribute__ ((noinline))
foo_r (long long x, int i)
{
  switch (i)
    {
    case 0:
      return _mm512_setr_epi64 (x, 0, 0, 0, 0, 0, 0, 0);
    case 1:
      return _mm512_setr_epi64 (0, x, 0, 0, 0, 0, 0, 0);
    case 2:
      return _mm512_setr_epi64 (0, 0, x, 0, 0, 0, 0, 0);
    case 3:
      return _mm512_setr_epi64 (0, 0, 0, x, 0, 0, 0, 0);
    case 4:
      return _mm512_setr_epi64 (0, 0, 0, 0, x, 0, 0, 0);
    case 5:
      return _mm512_setr_epi64 (0, 0, 0, 0, 0, x, 0, 0);
    case 6:
      return _mm512_setr_epi64 (0, 0, 0, 0, 0, 0, x, 0);
    case 7:
      return _mm512_setr_epi64 (0, 0, 0, 0, 0, 0, 0, x);
    default:
      abort ();
    }
}

static void
avx512f_test (void)
{
  long long e = 0xabadbeef01234567LL;
  long long v[8];
  union512i_q res;
  int i, j;

  for (i = 0; i < 8; i++)
    {
      for (j = 0; j < 8; j++)
	v[j] = 0;
      v[i] = e;

      res.x = foo (e, i);

      if (check_union512i_q (res, v))
	abort ();

      res.x = _mm512_setzero_si512 ();

      res.x = foo_r (e, i);

      if (check_union512i_q (res, v))
	abort ();
    }
}