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

Subversion Repositories openrisc

[/] [openrisc/] [tags/] [gnu-src/] [gcc-4.5.1/] [gcc-4.5.1-or32-1.0rc1/] [gcc/] [testsuite/] [gcc.target/] [i386/] [fma4-msubXX.c] - Diff between revs 318 and 338

Only display areas with differences | Details | Blame | View Log

Rev 318 Rev 338
/* { dg-do run } */
/* { dg-do run } */
/* { dg-require-effective-target fma4 } */
/* { dg-require-effective-target fma4 } */
/* { dg-options "-O0 -mfma4" } */
/* { dg-options "-O0 -mfma4" } */
 
 
#include "fma4-check.h"
#include "fma4-check.h"
 
 
#include <x86intrin.h>
#include <x86intrin.h>
#include <string.h>
#include <string.h>
 
 
#define NUM 20
#define NUM 20
 
 
union
union
{
{
  __m128 x[NUM];
  __m128 x[NUM];
  float f[NUM * 4];
  float f[NUM * 4];
  __m128d y[NUM];
  __m128d y[NUM];
  double d[NUM * 2];
  double d[NUM * 2];
} dst, res, src1, src2, src3;
} dst, res, src1, src2, src3;
 
 
/* Note that in macc*,msub*,mnmacc* and mnsub* instructions, the intermdediate
/* Note that in macc*,msub*,mnmacc* and mnsub* instructions, the intermdediate
   product is not rounded, only the addition is rounded. */
   product is not rounded, only the addition is rounded. */
 
 
static void
static void
init_msubps ()
init_msubps ()
{
{
  int i;
  int i;
  for (i = 0; i < NUM * 4; i++)
  for (i = 0; i < NUM * 4; i++)
    {
    {
      src1.f[i] = i;
      src1.f[i] = i;
      src2.f[i] = i + 10;
      src2.f[i] = i + 10;
      src3.f[i] = i + 20;
      src3.f[i] = i + 20;
    }
    }
}
}
 
 
static void
static void
init_msubpd ()
init_msubpd ()
{
{
  int i;
  int i;
  for (i = 0; i < NUM * 4; i++)
  for (i = 0; i < NUM * 4; i++)
    {
    {
      src1.d[i] = i;
      src1.d[i] = i;
      src2.d[i] = i + 10;
      src2.d[i] = i + 10;
      src3.d[i] = i + 20;
      src3.d[i] = i + 20;
    }
    }
}
}
 
 
static int
static int
check_msubps ()
check_msubps ()
{
{
  int i, j, check_fails = 0;
  int i, j, check_fails = 0;
  for (i = 0; i < NUM * 4; i = i + 4)
  for (i = 0; i < NUM * 4; i = i + 4)
    for (j = 0; j < 4; j++)
    for (j = 0; j < 4; j++)
      {
      {
        res.f[i + j] = (src1.f[i + j] * src2.f[i + j]) - src3.f[i + j];
        res.f[i + j] = (src1.f[i + j] * src2.f[i + j]) - src3.f[i + j];
        if (dst.f[i + j] != res.f[i + j])
        if (dst.f[i + j] != res.f[i + j])
          check_fails++;
          check_fails++;
      }
      }
  return check_fails++;
  return check_fails++;
}
}
 
 
static int
static int
check_msubpd ()
check_msubpd ()
{
{
  int i, j, check_fails = 0;
  int i, j, check_fails = 0;
  for (i = 0; i < NUM * 2; i = i + 2)
  for (i = 0; i < NUM * 2; i = i + 2)
    for (j = 0; j < 2; j++)
    for (j = 0; j < 2; j++)
      {
      {
        res.d[i + j] = (src1.d[i + j] * src2.d[i + j]) - src3.d[i + j];
        res.d[i + j] = (src1.d[i + j] * src2.d[i + j]) - src3.d[i + j];
        if (dst.d[i + j] != res.d[i + j])
        if (dst.d[i + j] != res.d[i + j])
          check_fails++;
          check_fails++;
      }
      }
  return check_fails++;
  return check_fails++;
}
}
 
 
 
 
static int
static int
check_msubss ()
check_msubss ()
{
{
  int i, j, check_fails = 0;
  int i, j, check_fails = 0;
  for (i = 0; i < NUM * 4; i = i + 4)
  for (i = 0; i < NUM * 4; i = i + 4)
    {
    {
      res.f[i] = (src1.f[i] * src2.f[i]) - src3.f[i];
      res.f[i] = (src1.f[i] * src2.f[i]) - src3.f[i];
      if (dst.f[i] != res.f[i])
      if (dst.f[i] != res.f[i])
        check_fails++;
        check_fails++;
    }
    }
  return check_fails++;
  return check_fails++;
}
}
 
 
static int
static int
check_msubsd ()
check_msubsd ()
{
{
  int i, j, check_fails = 0;
  int i, j, check_fails = 0;
  for (i = 0; i < NUM * 2; i = i + 2)
  for (i = 0; i < NUM * 2; i = i + 2)
    {
    {
      res.d[i] = (src1.d[i] * src2.d[i]) - src3.d[i];
      res.d[i] = (src1.d[i] * src2.d[i]) - src3.d[i];
      if (dst.d[i] != res.d[i])
      if (dst.d[i] != res.d[i])
        check_fails++;
        check_fails++;
    }
    }
  return check_fails++;
  return check_fails++;
}
}
 
 
static void
static void
fma4_test (void)
fma4_test (void)
{
{
  int i;
  int i;
 
 
  init_msubps ();
  init_msubps ();
 
 
  for (i = 0; i < NUM; i++)
  for (i = 0; i < NUM; i++)
    dst.x[i] = _mm_msub_ps (src1.x[i], src2.x[i], src3.x[i]);
    dst.x[i] = _mm_msub_ps (src1.x[i], src2.x[i], src3.x[i]);
 
 
  if (check_msubps ())
  if (check_msubps ())
    abort ();
    abort ();
 
 
  for (i = 0; i < NUM; i++)
  for (i = 0; i < NUM; i++)
    dst.x[i] = _mm_msub_ss (src1.x[i], src2.x[i], src3.x[i]);
    dst.x[i] = _mm_msub_ss (src1.x[i], src2.x[i], src3.x[i]);
 
 
  if (check_msubss ())
  if (check_msubss ())
    abort ();
    abort ();
 
 
  init_msubpd ();
  init_msubpd ();
 
 
  for (i = 0; i < NUM; i++)
  for (i = 0; i < NUM; i++)
    dst.y[i] = _mm_msub_pd (src1.y[i], src2.y[i], src3.y[i]);
    dst.y[i] = _mm_msub_pd (src1.y[i], src2.y[i], src3.y[i]);
 
 
  if (check_msubpd ())
  if (check_msubpd ())
    abort ();
    abort ();
 
 
  for (i = 0; i < NUM; i++)
  for (i = 0; i < NUM; i++)
    dst.y[i] = _mm_msub_sd (src1.y[i], src2.y[i], src3.y[i]);
    dst.y[i] = _mm_msub_sd (src1.y[i], src2.y[i], src3.y[i]);
 
 
  if (check_msubsd ())
  if (check_msubsd ())
    abort ();
    abort ();
}
}
 
 

powered by: WebSVN 2.1.0

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