summaryrefslogtreecommitdiff
path: root/libgfortran
diff options
context:
space:
mode:
authoruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>2013-12-01 20:56:21 +0000
committeruros <uros@138bc75d-0d04-0410-961f-82ee72b054a4>2013-12-01 20:56:21 +0000
commita3e65a1e9fce004f42a1cf4a136d90d3e3c15071 (patch)
tree1ff442c566c3f925f67f54bf23fc863ef83a86eb /libgfortran
parent6a6d2499056fc1d11de83f44aa1bb4caf0241a26 (diff)
downloadgcc-a3e65a1e9fce004f42a1cf4a136d90d3e3c15071.tar.gz
PR libfortran/59313
* intrinsics/erfc_scaled.c (erfc_scaled_r16): Also provide for quadruple precision long double variant. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@205574 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libgfortran')
-rw-r--r--libgfortran/ChangeLog6
-rw-r--r--libgfortran/intrinsics/erfc_scaled.c40
-rw-r--r--libgfortran/intrinsics/erfc_scaled_inc.c2
3 files changed, 36 insertions, 12 deletions
diff --git a/libgfortran/ChangeLog b/libgfortran/ChangeLog
index 5bded877e0f..a428205e562 100644
--- a/libgfortran/ChangeLog
+++ b/libgfortran/ChangeLog
@@ -1,3 +1,9 @@
+2013-12-01 Uros Bizjak <ubizjak@gmail.com>
+
+ PR libfortran/59313
+ * intrinsics/erfc_scaled.c (erfc_scaled_r16): Also provide for
+ quadruple precision long double variant.
+
2013-11-20 Francois-Xavier Coudert <fxcoudert@gcc.gnu.org>
* intrinsics/erfc_scaled.c (erfc_scaled_r16): Don't define if
diff --git a/libgfortran/intrinsics/erfc_scaled.c b/libgfortran/intrinsics/erfc_scaled.c
index f69e1fc7357..0498508a5bb 100644
--- a/libgfortran/intrinsics/erfc_scaled.c
+++ b/libgfortran/intrinsics/erfc_scaled.c
@@ -45,17 +45,34 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
#include "erfc_scaled_inc.c"
#endif
-#if defined(HAVE_GFC_REAL_16) && defined(GFC_REAL_16_IS_LONG_DOUBLE)
-#undef KIND
-#define KIND 16
-#include "erfc_scaled_inc.c"
-#endif
+#ifdef HAVE_GFC_REAL_16
+/* For quadruple-precision, netlib's implementation is
+ not accurate enough. We provide another one. */
#ifdef GFC_REAL_16_IS_FLOAT128
-/* For quadruple-precision (__float128), netlib's implementation is
- not accurate enough. We provide another one. */
+# define _THRESH -106.566990228185312813205074546585730Q
+# define _M_2_SQRTPI M_2_SQRTPIq
+# define _INF __builtin_infq()
+# define _ERFC(x) erfcq(x)
+# define _EXP(x) expq(x)
+
+#else
+
+# define _THRESH -106.566990228185312813205074546585730L
+# define _M_2_SQRTPI M_2_SQRTPIl
+# define _INF __builtin_infl()
+# ifdef HAVE_ERFCL
+# define _ERFC(x) erfcl(x)
+# endif
+# ifdef HAVE_EXPL
+# define _EXP(x) expl(x)
+# endif
+
+#endif
+
+#if defined(_ERFC) && defined(_EXP)
extern GFC_REAL_16 erfc_scaled_r16 (GFC_REAL_16);
export_proto(erfc_scaled_r16);
@@ -63,15 +80,15 @@ export_proto(erfc_scaled_r16);
GFC_REAL_16
erfc_scaled_r16 (GFC_REAL_16 x)
{
- if (x < -106.566990228185312813205074546585730Q)
+ if (x < _THRESH)
{
- return __builtin_infq();
+ return _INF;
}
if (x < 12)
{
/* Compute directly as ERFC_SCALED(x) = ERFC(x) * EXP(X**2).
This is not perfect, but much better than netlib. */
- return erfcq(x) * expq(x * x);
+ return _ERFC(x) * _EXP(x * x);
}
else
{
@@ -97,9 +114,10 @@ erfc_scaled_r16 (GFC_REAL_16 x)
n++;
}
- return (1 + sum) / x * (M_2_SQRTPIq / 2);
+ return (1 + sum) / x * (_M_2_SQRTPI / 2);
}
}
#endif
+#endif
diff --git a/libgfortran/intrinsics/erfc_scaled_inc.c b/libgfortran/intrinsics/erfc_scaled_inc.c
index 107d91a6c9d..b643edf43a4 100644
--- a/libgfortran/intrinsics/erfc_scaled_inc.c
+++ b/libgfortran/intrinsics/erfc_scaled_inc.c
@@ -39,7 +39,7 @@ see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
# define EXP(x) exp(x)
# define TRUNC(x) trunc(x)
-#elif (KIND == 10) || (KIND == 16 && defined(GFC_REAL_16_IS_LONG_DOUBLE))
+#elif (KIND == 10)
# ifdef HAVE_EXPL
# define EXP(x) expl(x)