summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gcc.target/i386/sse2-vec-3.c
blob: fa18de5a990fa99b13ca5d3967629d25bb1c7cc8 (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
/* { dg-do run } */
/* { dg-options "-O2 -msse2" } */
/* { dg-require-effective-target sse2 } */

#include "sse2-check.h"

#include <emmintrin.h>

static void
sse2_test (void)
{
  union
    {
      __m128i x;
      char c[16];
      short s[8];
      int i[4];
      long long ll[2];
    } val1;
  int res[4];
  int masks[4];
  int i;

  for (i = 0; i < 16; i++)
    val1.c[i] = i;

  res[0] = __builtin_ia32_vec_ext_v4si ((__v4si)val1.x, 0);
  res[1] = __builtin_ia32_vec_ext_v4si ((__v4si)val1.x, 1);
  res[2] = __builtin_ia32_vec_ext_v4si ((__v4si)val1.x, 2);
  res[3] = __builtin_ia32_vec_ext_v4si ((__v4si)val1.x, 3);

  for (i = 0; i < 4; i++)
    masks[i] = i;

  for (i = 0; i < 4; i++)
    if (res[i] != val1.i [masks[i]])
      abort ();
}