aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/aarch64/vrecpx.c
blob: 63097f1d9cf3209236cb79aba498669ebe5598a6 (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
48
49
50
51
52
53
54
/* { dg-do run } */
/* { dg-options "-O3 --save-temps" } */

#include <arm_neon.h>
#include <math.h>
#include <stdlib.h>

float32_t in_f[] =
{2.0, 4.0, 8.0, 16.0, 1.0, 0.5, 0.25, 0.125};
float32_t rec_f[] =
{1.0, 0.5, 0.25, 0.125, 2.0, 4.0, 8.0, 16.0};
float64_t in_d[] =
{2.0, 4.0, 8.0, 16.0, 1.0, 0.5, 0.25, 0.125};
float32_t rec_d[] =
{1.0, 0.5, 0.25, 0.125, 2.0, 4.0, 8.0, 16.0};

int
test_frecpx_float32_t (void)
{
  int i = 0;
  int ret = 1;
  for (i = 0; i < 8; i++)
    ret &= fabs (vrecpxs_f32 (in_f[i]) - rec_f[i]) < 0.001;

  return ret;
}

/* { dg-final { scan-assembler "frecpx\\ts\[0-9\]+, s\[0-9\]+" } } */

int
test_frecpx_float64_t (void)
{
  int i = 0;
  int ret = 1;
  for (i = 0; i < 8; i++)
    ret &= fabs (vrecpxd_f64 (in_d[i]) - rec_d[i]) < 0.001;

  return ret;
}

/* { dg-final { scan-assembler "frecpx\\td\[0-9\]+, d\[0-9\]+" } } */

int
main (int argc, char **argv)
{
  if (!test_frecpx_float32_t ())
    abort ();
  if (!test_frecpx_float64_t ())
    abort ();

  return 0;
}

/* { dg-final { cleanup-saved-temps } } */