1! { dg-do run { xfail spu-*-* } }
2! { dg-options "-fno-range-check -ffree-line-length-none -O0" }
3! { dg-add-options ieee }
4!
5! XFAILed for SPU targets because our library implementation of
6! the double-precision erf/erfc functions is not accurate enough.
7!
8! Check that simplification functions and runtime library agree on ERF,
9! ERFC and ERFC_SCALED.
10
11program test
12  implicit none
13
14  interface check
15    procedure check_r4
16    procedure check_r8
17  end interface check
18
19  real(kind=4) :: x4
20  real(kind=8) :: x8
21
22#define CHECK(a) \
23  x8 = a ; x4 = a ; \
24  call check(erf(real(a,kind=8)), erf(x8)) ; \
25  call check(erf(real(a,kind=4)), erf(x4)) ; \
26  call check(erfc(real(a,kind=8)), erfc(x8)) ; \
27  call check(erfc(real(a,kind=4)), erfc(x4)) ; \
28  call check(erfc_scaled(real(a,kind=8)), erfc_scaled(x8)) ; \
29  call check(erfc_scaled(real(a,kind=4)), erfc_scaled(x4)) ;
30
31  CHECK(0.0)
32  CHECK(0.9)
33  CHECK(1.9)
34  CHECK(19.)
35  CHECK(190.)
36
37  CHECK(-0.0)
38  CHECK(-0.9)
39  CHECK(-1.9)
40  CHECK(-19.)
41  CHECK(-190.)
42
43contains
44
45  subroutine check_r4 (a, b)
46    real(kind=4), intent(in) :: a, b
47    if (abs(a - b) > 10 * spacing(a)) call abort
48  end subroutine
49
50  subroutine check_r8 (a, b)
51    real(kind=8), intent(in) :: a, b
52    if (abs(a - b) > 10 * spacing(a)) call abort
53  end subroutine
54
55end program test
56