mpc/mpc-1.0.3-fmma.diff

77 lines
2.5 KiB
Diff
Raw Normal View History

From 36a84f43f326de14db888ba07936cc9621c23f19 Mon Sep 17 00:00:00 2001
From: Paul Zimmermann <Paul.Zimmermann@inria.fr>
Date: Sun, 10 Jan 2016 23:19:37 +0100
Subject: [PATCH] use mpfr_fmma and mpfr_fmms if provided by mpfr
---
configure.ac | 16 ++++++++++++++++
src/mul.c | 15 ++++++++++++---
2 files changed, 28 insertions(+), 3 deletions(-)
diff --git a/configure.ac b/configure.ac
index b6fa199..bdb21ff 100644
--- a/configure.ac
+++ b/configure.ac
@@ -165,6 +165,22 @@ AC_LINK_IFELSE(
AC_MSG_ERROR([libmpfr not found or uses a different ABI (including static vs shared).])
])
+AC_MSG_CHECKING(for mpfr_fmma)
+LIBS="-lmpfr $LIBS"
+AC_LINK_IFELSE(
+ [AC_LANG_PROGRAM(
+ [[#include "mpfr.h"]],
+ [[mpfr_t x; mpfr_fmma (x, x, x, x, x, 0);]]
+ )],
+ [
+ AC_MSG_RESULT(yes)
+ AC_DEFINE(HAVE_MPFR_FMMA, 1, [mpfr_fmma is present])
+ ],
+ [
+ AC_MSG_RESULT(no)
+ AC_DEFINE(HAVE_MPFR_FMMA, 0, [mpfr_fmma is not present])
+ ])
+
# Check for a recent GMP
# We only guarantee that with a *functional* and recent enough GMP version,
# MPC will compile; we do not guarantee that GMP will compile.
--- mpc-1.0.3/src/mul.c.orig 2015-02-16 13:37:30.000000000 +0100
+++ mpc-1.0.3/src/mul.c 2018-01-02 13:54:34.030414144 +0100
@@ -171,8 +171,9 @@
}
+#if HAVE_MPFR_FMMA == 0
static int
-mpfr_fmma (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr c,
+mpc_fmma (mpfr_ptr z, mpfr_srcptr a, mpfr_srcptr b, mpfr_srcptr c,
mpfr_srcptr d, int sign, mpfr_rnd_t rnd)
{
/* Computes z = ab+cd if sign >= 0, or z = ab-cd if sign < 0.
@@ -319,6 +320,7 @@
return inex;
}
+#endif
int
@@ -337,10 +339,17 @@
else
rop [0] = z [0];
+#if HAVE_MPFR_FMMA
inex = MPC_INEX (mpfr_fmma (mpc_realref (rop), mpc_realref (x), mpc_realref (y), mpc_imagref (x),
mpc_imagref (y), -1, MPC_RND_RE (rnd)),
mpfr_fmma (mpc_imagref (rop), mpc_realref (x), mpc_imagref (y), mpc_imagref (x),
mpc_realref (y), +1, MPC_RND_IM (rnd)));
+#else
+ inex = MPC_INEX (mpc_fmma (mpc_realref (rop), mpc_realref (x), mpc_realref (y), mpc_imagref (x),
+ mpc_imagref (y), -1, MPC_RND_RE (rnd)),
+ mpc_fmma (mpc_imagref (rop), mpc_realref (x), mpc_imagref (y), mpc_imagref (x),
+ mpc_realref (y), +1, MPC_RND_IM (rnd)));
+#endif
mpc_set (z, rop, MPC_RNDNN);
if (overlap)