public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "rsa at us dot ibm.com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sources.redhat.com
Subject: [Bug math/887] Math library function "logb" and "nextafter" inconsistent
Date: Mon, 26 Mar 2012 20:43:00 -0000	[thread overview]
Message-ID: <bug-887-131-90twhN4EV8@http.sourceware.org/bugzilla/> (raw)
In-Reply-To: <bug-887-131@http.sourceware.org/bugzilla/>

http://sourceware.org/bugzilla/show_bug.cgi?id=887

--- Comment #20 from Ryan S. Arnold <rsa at us dot ibm.com> 2012-03-26 20:09:40 UTC ---
Here's a more thorough patch which includes -frounding-math when building
s_logb.c and only tests on 'double'.

diff --git a/math/libm-test.inc b/math/libm-test.inc
index 3851855..df83a45 100644
--- a/math/libm-test.inc
+++ b/math/libm-test.inc
@@ -5000,6 +5000,41 @@ logb_test (void)
   END (logb);
 }

+static void
+logb_test_downward (void)
+{
+  int save_round_mode;
+  errno = 0;
+
+  FUNC(logb) (0);
+  if (errno == ENOSYS)
+    /* Function not implemented.  */
+    return;
+
+  START (logb_downward);
+
+  save_round_mode = fegetround ();
+
+  if (!fesetround (FE_DOWNWARD))
+    {
+
+      /* IEEE 754-2008 says (section 5.3.3) that "logB(1) is +0.".  Libm
+       * should not return -0 from logb in any rounding mode.  PowerPC32 is
+       * known to fail with this test for power4 and earlier hardware due
+       * the instructions available for the logb computation at the POWER4
+       * and earlier ISA level.  POWER4 uses an fsub in the calculation which
+       * propogates a negative sign in a downward rounding mode.  */
+
+#if defined TEST_DOUBLE
+      /* BZ #887 .*/
+      TEST_f_f (logb, 1.000e+0, plus_zero);
+#endif /* TEST_DOUBLE  */
+    }
+
+  fesetround (save_round_mode);
+
+  END (logb_downward);
+}

 static void
 lround_test (void)
@@ -7834,6 +7869,7 @@ main (int argc, char **argv)
   log1p_test ();
   log2_test ();
   logb_test ();
+  logb_test_downward ();
   modf_test ();
   ilogb_test ();
   scalb_test ();
diff --git a/sysdeps/powerpc/powerpc32/Makefile
b/sysdeps/powerpc/powerpc32/Makefile
index aa2d0b9..638e177 100644
--- a/sysdeps/powerpc/powerpc32/Makefile
+++ b/sysdeps/powerpc/powerpc32/Makefile
@@ -42,3 +42,9 @@ ifeq ($(subdir),elf)
 # extra shared linker files to link only into dl-allobjs.so
 sysdep-rtld-routines += dl-start
 endif
+
+# BZ #887 logb for powerpc32 power4 ISA and earlier exhibits a negative sign
+# on zero from a downward round.
+ifeq ($(subdir),math)
+CFLAGS-s_logb.c += -frounding-math
+endif

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


  parent reply	other threads:[~2012-03-26 20:10 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <bug-887-131@http.sourceware.org/bugzilla/>
2012-02-22 21:44 ` jsm28 at gcc dot gnu.org
2012-02-23 19:49 ` rsa at us dot ibm.com
2012-02-23 21:29 ` rsa at us dot ibm.com
2012-02-23 21:39 ` joseph at codesourcery dot com
2012-02-23 21:44 ` rsa at us dot ibm.com
2012-02-23 23:18 ` rsa at us dot ibm.com
2012-02-29 16:22 ` rsa at us dot ibm.com
2012-02-29 16:23 ` rsa at us dot ibm.com
2012-03-01 21:26 ` rsa at us dot ibm.com
2012-03-26 19:34 ` rsa at us dot ibm.com
2012-03-26 20:43 ` rsa at us dot ibm.com [this message]
2012-03-26 20:51 ` joseph at codesourcery dot com
2012-03-26 20:56 ` rsa at us dot ibm.com
2012-03-26 20:57 ` rsa at us dot ibm.com
2012-03-26 22:23 ` rsa at us dot ibm.com
2012-04-25 22:01 ` rsa at us dot ibm.com
2012-04-26 18:16 ` rsa at us dot ibm.com
2012-04-26 18:53 ` joseph at codesourcery dot com
2012-04-26 19:04 ` rsa at us dot ibm.com
2012-04-27 16:31 ` rsa at us dot ibm.com
2014-01-07 22:43 ` cvs-commit at gcc dot gnu.org
2015-10-01 21:50 ` jsm28 at gcc dot gnu.org
2015-10-01 21:51 ` jsm28 at gcc dot gnu.org
2015-10-05 17:48 ` cvs-commit at gcc dot gnu.org
2015-10-05 17:50 ` cvs-commit at gcc dot gnu.org
2015-10-05 17:51 ` jsm28 at gcc dot gnu.org
2005-04-28 17:50 [Bug math/887] New: " uttamp at us dot ibm dot com
2005-04-29 20:38 ` [Bug math/887] " uttamp at us dot ibm dot com
2005-06-16 19:12 ` uttamp at us dot ibm dot com
2005-07-19 22:16 ` uttamp at us dot ibm dot com
2005-10-25 17:05 ` uttamp at us dot ibm dot com
2005-11-02  1:29 ` uttamp at us dot ibm dot com
2005-11-21 17:57 ` uttamp at us dot ibm dot com
2005-11-21 18:07 ` jakub at redhat dot com
2006-09-30  5:03 ` rsa at us dot ibm dot com
2006-09-30  5:54 ` rsa at us dot ibm dot com

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=bug-887-131-90twhN4EV8@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sources.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).