public inbox for libc-ports@sourceware.org
 help / color / mirror / Atom feed
From: Richard Henderson <rth@twiddle.net>
To: "Joseph S. Myers" <joseph@codesourcery.com>
Cc: libc-alpha@sourceware.org, libc-ports@sourceware.org,
	 Marcus Shawcroft <marcus.shawcroft@linaro.org>,
	Richard Henderson <rth@redhat.com>,
	 David Holsgrove <david.holsgrove@xilinx.com>,
	Chris Metcalf <cmetcalf@tilera.com>,
	 "David S. Miller" <davem@davemloft.net>
Subject: Re: Implement fma in soft-fp
Date: Tue, 25 Jun 2013 16:31:00 -0000	[thread overview]
Message-ID: <51C9C5F5.1070809@twiddle.net> (raw)
In-Reply-To: <Pine.LNX.4.64.1306221707230.15367@digraph.polyomino.org.uk>

[-- Attachment #1: Type: text/plain, Size: 1321 bytes --]

With the following patch, I get

> testing long double (without inline functions)
> Failure: fma (0x1.fffffffffffffffffffffffffffcp-16382, 0x1.0000000000000000000000000001p-1, 0x1p-16494): Exception "Underflow" set
> Failure: fma (-0x1.fffffffffffffffffffffffffffcp-16382, 0x1.0000000000000000000000000001p-1, -0x1p-16494): Exception "Underflow" set
> Failure: fma (0x1p-16494, -0x1p-16494, 0x1p-16382): Exception "Underflow" set
> Failure: fma (0x1p-16494, 0x1p-16494, -0x1p-16382): Exception "Underflow" set
> Failure: fma_downward (-0x1.fffffffffffffffffffffffffffcp-16382, 0x1.0000000000000000000000000001p-1, -0x1p-16494): Exception "Underflow" set
> Failure: fma_downward (-0x1p-16494, 0x1.1p-1, -0x0.ffffffffffffffffffffffffffffp-16382): Exception "Underflow" set
> Failure: fma_downward (0x1p-16494, 0x1p-16494, -0x1p-16382): Exception "Underflow" set
> Failure: fma_upward (0x1.fffffffffffffffffffffffffffcp-16382, 0x1.0000000000000000000000000001p-1, 0x1p-16494): Exception "Underflow" set
> Failure: fma_upward (0x1p-16494, 0x1.1p-1, 0x0.ffffffffffffffffffffffffffffp-16382): Exception "Underflow" set
> Failure: fma_upward (0x1p-16494, -0x1p-16494, 0x1p-16382): Exception "Underflow" set

but I thought you'd already committed the patch to solve this
as commit 695c378f81263640618bdebf56eaa065f578251f ?


r~

[-- Attachment #2: z --]
[-- Type: text/plain, Size: 3765 bytes --]

diff --git a/ports/sysdeps/alpha/Implies b/ports/sysdeps/alpha/Implies
index d03783b..35ccba3 100644
--- a/ports/sysdeps/alpha/Implies
+++ b/ports/sysdeps/alpha/Implies
@@ -1,7 +1,7 @@
 wordsize-64
+alpha/soft-fp
 # Alpha uses IEEE 754 single, double and quad precision floating point.
 ieee754/ldbl-128
 ieee754/dbl-64/wordsize-64
 ieee754/dbl-64
 ieee754/flt-32
-alpha/soft-fp
diff --git a/ports/sysdeps/alpha/soft-fp/s_fmal.c b/ports/sysdeps/alpha/soft-fp/s_fmal.c
new file mode 100644
index 0000000..8eae7fb
--- /dev/null
+++ b/ports/sysdeps/alpha/soft-fp/s_fmal.c
@@ -0,0 +1,52 @@
+/* Implement fmal using soft-fp.
+   Copyright (C) 2013 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   In addition to the permissions in the GNU Lesser General Public
+   License, the Free Software Foundation gives you unlimited
+   permission to link the compiled version of this file into
+   combinations with other programs, and to distribute those
+   combinations without any restriction coming from the use of this
+   file.  (The Lesser General Public License restrictions do apply in
+   other respects; for example, they cover modification of the file,
+   and distribution when not linked into a combine executable.)
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, see
+   <http://www.gnu.org/licenses/>.  */
+
+#include <math.h>
+#include <soft-fp.h>
+#include <quad.h>
+#include <math_ldbl_opt.h>
+
+long double
+__fmal (long double a, long double b, long double c)
+{
+  FP_DECL_EX;
+  FP_DECL_Q(A); FP_DECL_Q(B); FP_DECL_Q(C); FP_DECL_Q(R);
+  long double r;
+  long _round = 4;	/* dynamic rounding */
+
+  FP_INIT_ROUNDMODE;
+  FP_UNPACK_Q(A, a);
+  FP_UNPACK_Q(B, b);
+  FP_UNPACK_Q(C, c);
+  FP_FMA_Q(R, A, B, C);
+  FP_PACK_Q(r, R);
+  FP_HANDLE_EXCEPTIONS;
+
+  return r;
+}
+
+long_double_symbol (libm, __fmal, fmal);
diff --git a/ports/sysdeps/alpha/soft-fp/sfp-machine.h b/ports/sysdeps/alpha/soft-fp/sfp-machine.h
index be266fe..98e9850 100644
--- a/ports/sysdeps/alpha/soft-fp/sfp-machine.h
+++ b/ports/sysdeps/alpha/soft-fp/sfp-machine.h
@@ -34,6 +34,13 @@
 #define _FP_MUL_MEAT_Q(R,X,Y)					\
   _FP_MUL_MEAT_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
 
+#define _FP_MUL_MEAT_DW_S(R,X,Y)				\
+  _FP_MUL_MEAT_DW_1_imm(_FP_WFRACBITS_S,R,X,Y)
+#define _FP_MUL_MEAT_DW_D(R,X,Y)				\
+  _FP_MUL_MEAT_DW_1_wide(_FP_WFRACBITS_D,R,X,Y,umul_ppmm)
+#define _FP_MUL_MEAT_DW_Q(R,X,Y)				\
+  _FP_MUL_MEAT_DW_2_wide(_FP_WFRACBITS_Q,R,X,Y,umul_ppmm)
+
 #define _FP_DIV_MEAT_S(R,X,Y)	_FP_DIV_MEAT_1_imm(S,R,X,Y,_FP_DIV_HELP_imm)
 #define _FP_DIV_MEAT_D(R,X,Y)	_FP_DIV_MEAT_1_udiv_norm(D,R,X,Y)
 #define _FP_DIV_MEAT_Q(R,X,Y)	_FP_DIV_MEAT_2_udiv(Q,R,X,Y)
diff --git a/ports/sysdeps/unix/sysv/linux/alpha/Implies b/ports/sysdeps/unix/sysv/linux/alpha/Implies
index 1616efe..2a14f00 100644
--- a/ports/sysdeps/unix/sysv/linux/alpha/Implies
+++ b/ports/sysdeps/unix/sysv/linux/alpha/Implies
@@ -1,4 +1,6 @@
 unix/sysv/linux/wordsize-64
+# Select the soft-fp versions of some long double implementations.
+alpha/soft-fp
 # These supply the ABI compatibility for when long double was double.
 ieee754/ldbl-64-128
 ieee754/ldbl-opt

  parent reply	other threads:[~2013-06-25 16:31 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-06-22 17:17 Joseph S. Myers
2013-06-25 15:30 ` Richard Henderson
2013-06-25 16:13   ` Joseph S. Myers
2013-06-25 16:23     ` Richard Henderson
2013-06-25 16:31 ` Richard Henderson [this message]
2013-06-25 16:45   ` Joseph S. Myers
2013-06-27 23:26 ` Joseph S. Myers
2013-07-02 12:57   ` Ping " Joseph S. Myers
2013-07-02 14:45     ` Richard Henderson

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=51C9C5F5.1070809@twiddle.net \
    --to=rth@twiddle.net \
    --cc=cmetcalf@tilera.com \
    --cc=davem@davemloft.net \
    --cc=david.holsgrove@xilinx.com \
    --cc=joseph@codesourcery.com \
    --cc=libc-alpha@sourceware.org \
    --cc=libc-ports@sourceware.org \
    --cc=marcus.shawcroft@linaro.org \
    --cc=rth@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).