OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-old/] [gcc-4.2.2/] [gcc/] [testsuite/] [gcc.target/] [i386/] [sse3-hsubpd.c] - Blame information for rev 844

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 149 jeremybenn
/* { dg-do run { target i?86-*-* x86_64-*-* } } */
2
/* { dg-options "-O2 -msse3" } */
3
#include <pmmintrin.h>
4
#include <stdlib.h>
5
#include "../../gcc.dg/i386-cpuid.h"
6
 
7
static void sse3_test (void);
8
 
9
int
10
main ()
11
{
12
  unsigned long cpu_facilities;
13
 
14
  cpu_facilities = i386_cpuid_ecx ();
15
 
16
  /* Run SSE3 test only if host has SSE3 support.  */
17
  if ((cpu_facilities & bit_SSE3))
18
    sse3_test ();
19
 
20
  exit (0);
21
}
22
 
23
static void
24
sse3_test_hsubpd (double *i1, double *i2, double *r)
25
{
26
  __m128d t1 = _mm_loadu_pd (i1);
27
  __m128d t2 = _mm_loadu_pd (i2);
28
 
29
  t1 = _mm_hsub_pd (t1, t2);
30
 
31
  _mm_storeu_pd (r, t1);
32
}
33
 
34
static void
35
sse3_test_hsubpd_subsume (double *i1, double *i2, double *r)
36
{
37
  __m128d t1 = _mm_load_pd (i1);
38
  __m128d t2 = _mm_load_pd (i2);
39
 
40
  t1 = _mm_hsub_pd (t1, t2);
41
 
42
  _mm_storeu_pd (r, t1);
43
}
44
 
45
static int
46
chk_pd (double *v1, double *v2)
47
{
48
  int i;
49
  int n_fails = 0;
50
 
51
  for (i = 0; i < 2; i++)
52
    if (v1[i] != v2[i])
53
      n_fails += 1;
54
 
55
  return n_fails;
56
}
57
 
58
static double p1[2] __attribute__ ((aligned(16)));
59
static double p2[2] __attribute__ ((aligned(16)));
60
static double p3[2];
61
static double ck[2];
62
 
63
static double vals[80] =
64
  {
65
    100.0,  200.0, 300.0, 400.0, 5.0, -1.0, .345, -21.5,
66
    1100.0, 0.235, 321.3, 53.40, 0.3, 10.0, 42.0, 32.52,
67
    32.6,   123.3, 1.234, 2.156, 0.1, 3.25, 4.75, 32.44,
68
    12.16,  52.34, 64.12, 71.13, -.1, 2.30, 5.12, 3.785,
69
    541.3,  321.4, 231.4, 531.4, 71., 321., 231., -531.,
70
    23.45,  23.45, 23.45, 23.45, 23.45, 23.45, 23.45, 23.45,
71
    23.45,  -1.43, -6.74, 6.345, -20.1, -20.1, -40.1, -40.1,
72
    1.234,  2.345, 3.456, 4.567, 5.678, 6.789, 7.891, 8.912,
73
    -9.32,  -8.41, -7.50, -6.59, -5.68, -4.77, -3.86, -2.95,
74
    9.32,  8.41, 7.50, 6.59, -5.68, -4.77, -3.86, -2.95
75
  };
76
 
77
static void
78
sse3_test (void)
79
{
80
  int i;
81
  int fail = 0;
82
 
83
  for (i = 0; i < 80; i += 4)
84
    {
85
      p1[0] = vals[i+0];
86
      p1[1] = vals[i+1];
87
 
88
      p2[0] = vals[i+2];
89
      p2[1] = vals[i+3];
90
 
91
      ck[0] = p1[0] - p1[1];
92
      ck[1] = p2[0] - p2[1];
93
 
94
      sse3_test_hsubpd (p1, p2, p3);
95
 
96
      fail += chk_pd (ck, p3);
97
 
98
      sse3_test_hsubpd_subsume (p1, p2, p3);
99
 
100
      fail += chk_pd (ck, p3);
101
    }
102
 
103
  if (fail != 0)
104
    abort ();
105
}

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.