This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
Re: [PATCH]: PR fortran/33197, use MPC for complex "arc" functions
On Fri, 2 Oct 2009, Janis Johnson wrote:
> See the folding tests in gcc.dg, like builtins-7.c. Tests that are not
> run use { dg-do link } with calls to non-existent function link_error,
> causing a link error if the expression is not folded. The end result
> is the same as checking that there are no calls to abort, but it's a bit
> easier to understand the test. The same trick could be used in an
> executable self-checking test.
The test below seems to work using the link_error() style. (It was mostly
copied from complex_intrinsic_7.f90 with the numeric details changed).
Fortran doesn't seem to require any analogous "extern void link_error()"
declaration. So just replacing "call abort()" with "call link_error()"
was apparently enough.
This testcase requires the following patch so that the "mpc_arc"
effective target support is in place:
http://gcc.gnu.org/ml/gcc-patches/2009-09/msg02162.html
Tested with the above patch on x86_64-unknown-linux-gnu without mpc, with
mpc-0.7 and with svn mpc. No regressions and the new fortran testcase
passes in the latter configuration (and is "unsupported" in the others).
Okay for mainline once the above patch is approved?
Thanks,
--Kaveh
2009-10-05 Kaveh R. Ghazi <ghazi@caip.rutgers.edu>
* gfortran.dg/complex_intrinsic_8.f90: New test.
diff -rup orig/egcc-SVN20091005/gcc/testsuite/gfortran.dg/complex_intrinsic_8.f90 egcc-SVN20091005/gcc/testsuite/gfortran.dg/complex_intrinsic_8.f90
--- orig/egcc-SVN20091005/gcc/testsuite/gfortran.dg/complex_intrinsic_8.f90 2009-10-05 06:48:09.000000000 +0200
+++ egcc-SVN20091005/gcc/testsuite/gfortran.dg/complex_intrinsic_8.f90 2009-10-05 06:40:55.000000000 +0200
@@ -0,0 +1,50 @@
+! { dg-do link }
+! { dg-require-effective-target mpc_arc }
+!
+! PR fortran/33197
+!
+! Fortran complex trigonometric functions: acos, asin, atan, acosh, asinh, atanh
+!
+! Compile-time simplificiations
+!
+implicit none
+real(4), parameter :: pi = 2*acos(0.0_4)
+real(8), parameter :: pi8 = 2*acos(0.0_8)
+real(4), parameter :: eps = 10*epsilon(0.0_4)
+real(8), parameter :: eps8 = 10*epsilon(0.0_8)
+complex(4), parameter :: z0_0 = cmplx(0.0_4, 0.0_4, kind=4)
+complex(4), parameter :: z1_1 = cmplx(1.0_4, 1.0_4, kind=4)
+complex(8), parameter :: z80_0 = cmplx(0.0_8, 0.0_8, kind=8)
+complex(8), parameter :: z81_1 = cmplx(1.0_8, 1.0_8, kind=8)
+
+if (abs(acos(z0_0) - cmplx(pi/2,-0.0,4)) > eps) call link_error()
+if (abs(acos(z1_1) - cmplx(0.904556894, -1.06127506,4)) > eps) call link_error()
+if (abs(acos(z80_0) - cmplx(pi8/2,-0.0_8,8)) > eps8) call link_error()
+if (abs(acos(z81_1) - cmplx(0.90455689430238140_8, -1.0612750619050357_8,8)) > eps8) call link_error()
+
+if (abs(asin(z0_0) - cmplx(0.0,0.0,4)) > eps) call link_error()
+if (abs(asin(z1_1) - cmplx(0.66623943, 1.06127506,4)) > eps) call link_error()
+if (abs(asin(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call link_error()
+if (abs(asin(z81_1) - cmplx(0.66623943249251527_8, 1.0612750619050357_8,8)) > eps8) call link_error()
+
+if (abs(atan(z0_0) - cmplx(0.0,0.0,4)) > eps) call link_error()
+if (abs(atan(z1_1) - cmplx(1.01722196, 0.40235947,4)) > eps) call link_error()
+if (abs(atan(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call link_error()
+if (abs(atan(z81_1) - cmplx(1.0172219678978514_8, 0.40235947810852507_8,8)) > eps8) call link_error()
+
+if (abs(acosh(z0_0) - cmplx(0.0,pi/2,4)) > eps) call link_error()
+if (abs(acosh(z1_1) - cmplx(1.06127506, 0.90455689,4)) > eps) call link_error()
+if (abs(acosh(z80_0) - cmplx(0.0_8,pi8/2,8)) > eps8) call link_error()
+if (abs(acosh(z81_1) - cmplx(1.0612750619050357_8, 0.90455689430238140_8,8)) > eps8) call link_error()
+
+if (abs(asinh(z0_0) - cmplx(0.0,0.0,4)) > eps) call link_error()
+if (abs(asinh(z1_1) - cmplx(1.06127506, 0.66623943,4)) > eps) call link_error()
+if (abs(asinh(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call link_error()
+if (abs(asinh(z81_1) - cmplx(1.0612750619050357_8, 0.66623943249251527_8,8)) > eps8) call link_error()
+
+if (abs(atanh(z0_0) - cmplx(0.0,0.0,4)) > eps) call link_error()
+if (abs(atanh(z1_1) - cmplx(0.40235947, 1.01722196,4)) > eps) call link_error()
+if (abs(atanh(z80_0) - cmplx(0.0_8,0.0_8,8)) > eps8) call link_error()
+if (abs(atanh(z81_1) - cmplx(0.40235947810852507_8, 1.0172219678978514_8,8)) > eps8) call link_error()
+
+end