This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
[PATCH] Avoid broken powf on hppa*64*-*-hpux*
- From: "John David Anglin" <dave at hiauly1 dot hia dot nrc dot ca>
- To: gcc-patches at gcc dot gnu dot org, fortran at gcc dot gnu dot org
- Cc: sje at cup dot hp dot com
- Date: Sun, 28 Dec 2008 11:20:51 -0500 (EST)
- Subject: [PATCH] Avoid broken powf on hppa*64*-*-hpux*
The attached patch seems like the simplest way to fix the failure of
gfortran.dg/integer_exponentiation_2.f90 at -O1 and above. As noted
in the PR, the current powf implementation on 64-bit HP-UX is broken,
clobbering register %fr12.
This patch adds a check for a broken powf and uses the internal powf
implementation in c99_functions.c if powf is broken. At the moment,
the check is only a target check. An actual runtime check would need
to be written in assembly language, and this would only work in native
builds. As far as I know, all HP-UX versions are affected.
Tested on hppa64-hp-hpux11.11 and hppa2.0w-hp-hpux11.11 with no
regressions.
Ok?
Dave
--
J. David Anglin dave.anglin@nrc-cnrc.gc.ca
National Research Council of Canada (613) 990-0752 (FAX: 952-6602)
2008-12-28 John David Anglin <dave.anglin@nrc-cnrc.gc.ca>
PR fortran/31832
* acinclude.m4 (LIBGFOR_CHECK_FOR_BROKEN_POWF): New autoconf check for
broken powf.
* configure.ac (LIBGFOR_CHECK_FOR_BROKEN_POWF): Use it.
* intrinsics/c99_functions.c: Use internal powf implementation if
HAVE_BROKEN_POWF is defined.
* configure: Rebuilt.
* config.h.in: Rebuilt.
Index: acinclude.m4
===================================================================
--- acinclude.m4 (revision 142927)
+++ acinclude.m4 (working copy)
@@ -376,3 +376,15 @@
AC_DEFINE(HAVE_MINGW_SNPRINTF, 1, [Define if you have __mingw_snprintf.])
fi
])
+
+dnl Check whether we have a broken powf implementation
+AC_DEFUN([LIBGFOR_CHECK_FOR_BROKEN_POWF], [
+ AC_CACHE_CHECK([whether powf is broken], libgfor_cv_have_broken_powf, [
+case "${target}" in
+ hppa*64*-*-hpux*) libgfor_cv_have_broken_powf=yes ;;
+ *) libgfor_cv_have_broken_powf=no;;
+esac])
+ if test x"$libgfor_cv_have_broken_powf" = xyes; then
+ AC_DEFINE(HAVE_BROKEN_POWF, 1, [Define if powf is broken.])
+ fi
+])
Index: configure.ac
===================================================================
--- configure.ac (revision 142927)
+++ configure.ac (working copy)
@@ -405,6 +405,9 @@
# Check whether __mingw_snprintf() is present
LIBGFOR_CHECK_MINGW_SNPRINTF
+# Check for a broken powf implementation
+LIBGFOR_CHECK_FOR_BROKEN_POWF
+
# Check for GNU libc feenableexcept
AC_CHECK_LIB([m],[feenableexcept],[have_feenableexcept=yes AC_DEFINE([HAVE_FEENABLEEXCEPT],[1],[libm includes feenableexcept])])
Index: intrinsics/c99_functions.c
===================================================================
--- intrinsics/c99_functions.c (revision 142927)
+++ intrinsics/c99_functions.c (working copy)
@@ -491,7 +491,7 @@
#endif
-#ifndef HAVE_POWF
+#if !defined(HAVE_POWF) || defined(HAVE_BROKEN_POWF)
#define HAVE_POWF 1
float
powf(float x, float y)