summaryrefslogtreecommitdiff
path: root/gcc/testsuite/g++.dg/other/pr40446.C
blob: dd0aa4820750b11ec7951ba7edfcb00fd8b568ce (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
// PR middle-end/40446
// { dg-do run { target i?86-*-* x86_64-*-* } }
// { dg-options "-O1 -msse2" }
// { dg-require-effective-target sse2 }

#include <emmintrin.h>
#include "cpuid.h"

extern "C" void abort ();

struct S
{
  S (double r, double i) { __real__ s = r; __imag__ s = i; }
  __complex__ double s;
};

__m128d
foo ()
{
  S c (0, 1);
  return _mm_load_pd ((double *) &c);
}

static void
__attribute__((noinline))
sse2_test ()
{
  union { __m128d vec; double val[2]; } u;
  u.vec = foo ();
  if (u.val[0] != 0 || u.val[1] != 1)
    abort ();
}

int
main ()
{
  unsigned int eax, ebx, ecx, edx;

  if (!__get_cpuid (1, &eax, &ebx, &ecx, &edx))
    return 0;

  /* Run SSE2 test only if host has SSE2 support.  */
  if (edx & bit_SSE2)
    sse2_test ();

  return 0;
}