aboutsummaryrefslogtreecommitdiffstats
path: root/gcc-4.9/gcc/testsuite/gcc.target/aarch64/vsqrt.c
blob: 5b777b236dae3e9bf3d7d7712c00ac52c8b46d59 (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72


/* { dg-do run } */
/* { dg-options "-O3" } */

#include "arm_neon.h"
#include "stdio.h"

extern void abort (void);

void
test_square_root_v2sf ()
{
  const float32_t pool[] = {4.0f, 9.0f};
  float32x2_t val;
  float32x2_t res;

  val = vld1_f32 (pool);
  res = vsqrt_f32 (val);

  if (vget_lane_f32 (res, 0) != 2.0f)
    abort ();
  if (vget_lane_f32 (res, 1) != 3.0f)
    abort ();
}

void
test_square_root_v4sf ()
{
  const float32_t pool[] = {4.0f, 9.0f, 16.0f, 25.0f};
  float32x4_t val;
  float32x4_t res;

  val = vld1q_f32 (pool);
  res = vsqrtq_f32 (val);

  if (vgetq_lane_f32 (res, 0) != 2.0f)
    abort ();
  if (vgetq_lane_f32 (res, 1) != 3.0f)
    abort ();
  if (vgetq_lane_f32 (res, 2) != 4.0f)
    abort ();
  if (vgetq_lane_f32 (res, 3) != 5.0f)
    abort ();
}

void
test_square_root_v2df ()
{
  const float64_t pool[] = {4.0, 9.0};
  float64x2_t val;
  float64x2_t res;

  val = vld1q_f64 (pool);
  res = vsqrtq_f64 (val);

  if (vgetq_lane_f64 (res, 0) != 2.0)
    abort ();

  if (vgetq_lane_f64 (res, 1) != 3.0)
    abort ();
}

int
main (void)
{
  test_square_root_v2sf ();
  test_square_root_v4sf ();
  test_square_root_v2df ();

  return 0;
}