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

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [gcc.target/] [i386/] [fma4-256-maccXX.c] - Blame information for rev 318

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 318 jeremybenn
/* { dg-do run } */
2
/* { dg-require-effective-target fma4 } */
3
/* { dg-options "-O2 -mfma4" } */
4
 
5
#include "fma4-check.h"
6
 
7
#include <x86intrin.h>
8
#include <string.h>
9
 
10
#define NUM 20
11
 
12
union
13
{
14
  __m256 x[NUM];
15
  float f[NUM * 8];
16
  __m256d y[NUM];
17
  double d[NUM * 4];
18
} dst, res, src1, src2, src3;
19
 
20
 
21
/* Note that in macc*,msub*,mnmacc* and mnsub* instructions, the intermdediate
22
   product is not rounded, only the addition is rounded. */
23
 
24
static void
25
init_maccps ()
26
{
27
  int i;
28
  for (i = 0; i < NUM * 8; i++)
29
    {
30
      src1.f[i] = i;
31
      src2.f[i] = i + 10;
32
      src3.f[i] = i + 20;
33
    }
34
}
35
 
36
static void
37
init_maccpd ()
38
{
39
  int i;
40
  for (i = 0; i < NUM * 4; i++)
41
    {
42
      src1.d[i] = i;
43
      src2.d[i] = i + 10;
44
      src3.d[i] = i + 20;
45
    }
46
}
47
 
48
static int
49
check_maccps ()
50
{
51
  int i, j, check_fails = 0;
52
  for (i = 0; i < NUM * 8; i = i + 8)
53
    for (j = 0; j < 8; j++)
54
      {
55
        res.f[i + j] = (src1.f[i + j] * src2.f[i + j]) + src3.f[i + j];
56
        if (dst.f[i + j] != res.f[i + j])
57
          check_fails++;
58
      }
59
  return check_fails++;
60
}
61
 
62
static int
63
check_maccpd ()
64
{
65
  int i, j, check_fails = 0;
66
  for (i = 0; i < NUM * 4; i = i + 4)
67
    for (j = 0; j < 4; j++)
68
      {
69
        res.d[i + j] = (src1.d[i + j] * src2.d[i + j]) + src3.d[i + j];
70
        if (dst.d[i + j] != res.d[i + j])
71
          check_fails++;
72
      }
73
  return check_fails++;
74
}
75
 
76
static void
77
fma4_test (void)
78
{
79
  int i;
80
 
81
  init_maccps ();
82
 
83
  for (i = 0; i < NUM; i++)
84
    dst.x[i] = _mm256_macc_ps (src1.x[i], src2.x[i], src3.x[i]);
85
 
86
  if (check_maccps ())
87
    abort ();
88
 
89
  init_maccpd ();
90
 
91
  for (i = 0; i < NUM; i++)
92
    dst.y[i] = _mm256_macc_pd (src1.y[i], src2.y[i], src3.y[i]);
93
 
94
  if (check_maccpd ())
95
    abort ();
96
}

powered by: WebSVN 2.1.0

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