public inbox for libc-hacker@sourceware.org
 help / color / mirror / Atom feed
From: Steven Munroe <munroesj@us.ibm.com>
To: Glibc hackers <libc-hacker@sources.redhat.com>
Cc: Jakub Jelinek <jakub@redhat.com>,
	Ulrich Drepper <drepper@redhat.com>,
	Peter Eberlein <eberlein@us.ibm.com>
Subject: [PATCH] PPC fenv fixes.
Date: Tue, 27 Mar 2007 15:53:00 -0000	[thread overview]
Message-ID: <460941B8.2050501@us.ibm.com> (raw)
In-Reply-To: <4602FCE5.7060203@us.ibm.com>

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

Steven Munroe wrote:
> Jakub Jelinek wrote:
>   
>> Hi!
>>
>> feholdexcept is supposed to clear the sticky exception bits:
>> "The feholdexcept function saves the current floating-point environment in the object
>> pointed to by envp, clears the floating-point status flags, and then installs a non-stop
>> (continue on floating-point exceptions) mode, if available, for all floating-point
>> exceptions."
>> and
>> "A floating-point status flag is a system variable whose value is set
>> (but never cleared) when a floating-point exception is raised, which occurs as a side effect
>> of exceptional floating-point arithmetic to provide auxiliary information."
>>
>> Several feholdexcept implementations didn't handle this right.
>> Also, e.g. feupdateenv was a stub on x86_64 eventhough it is IMHO easily
>> implementable and other arches had bugs in it too (e.g. ia64 would rise
>> wrong exceptions and always return a failure).
>> I added a new testcase for feholdexcept/feupdateenv (hopefully I haven't
>> misinterpreted the standard) and I believe other arches (ppc*, s390*, ...)
>> will need some care too.
>>   
>>     
>
> powerpc32 and powerpc64 both show two failures with the new test-fenv:
>
> Test: feholdexcept_tests FE_DIVBYZERO|FE_INVALID test
>   Fail: Exception "DIVBYZERO" is not set
>   Pass: Exception "INVALID" is set
>   Pass: Exception "INEXACT" is not set
>   Pass: Exception "UNDERFLOW" is not set
>   Pass: Exception "OVERFLOW" is not set
>
> and
>
> Test: feholdexcept_tests FE_INEXACT|FE_INVALID test
>   Pass: Exception "DIVBYZERO" is not set
>   Fail: Exception "INVALID" is not set
>   Pass: Exception "INEXACT" is set
>   Pass: Exception "UNDERFLOW" is not set
>   Pass: Exception "OVERFLOW" is not set
>
> We will look into this.
>   
feupdateenv was not merging pending and current exceptions correctly and
caused 2 failures with the new feholdexcept tests. The attached patch
fixes feupdateenv for ppc32/ppc64.



[-- Attachment #2: ppc-feupdateenv-20070327.txt --]
[-- Type: text/plain, Size: 1283 bytes --]

2007-03-26  Steven Munroe  <sjmunroe@us.ibm.com>

	* sysdeps/powerpc/fpu/feupdateenv.c: Change mask to merge exceptions
	from env.


diff -urN libc25-cvstip-20070320/sysdeps/powerpc/fpu/feupdateenv.c libc25/sysdeps/powerpc/fpu/feupdateenv.c
--- libc25-cvstip-20070320/sysdeps/powerpc/fpu/feupdateenv.c	2001-07-05 23:56:02.000000000 -0500
+++ libc25/sysdeps/powerpc/fpu/feupdateenv.c	2007-03-27 09:13:54.875363776 -0500
@@ -1,5 +1,5 @@
 /* Install given floating-point environment and raise exceptions.
-   Copyright (C) 1997,99,2000,01 Free Software Foundation, Inc.
+   Copyright (C) 1997,99,2000,01,07 Free Software Foundation, Inc.
    This file is part of the GNU C Library.
    Contributed by Ulrich Drepper <drepper@cygnus.com>, 1997.
 
@@ -30,8 +30,10 @@
   new.fenv = *envp;
   old.fenv = fegetenv_register ();
 
-  /* Copy the set exceptions from `old' to `new'.  */
-  new.l[1] = (new.l[1] & 0xE00000FF) | (old.l[1] & 0x1FFFFF00);
+  /* Restore rounding mode and exception enable from *envp and merge
+     exceptions.  Leave fraction rounded/inexact and FP result/CC bits
+     unchanged.  */
+  new.l[1] = (old.l[1] & 0x1FFFFF00) | (new.l[1] & 0x1FF80FFF);
 
   /* Atomically enable and raise (if appropriate) exceptions set in `new'. */
   fesetenv_register (new.fenv);

  reply	other threads:[~2007-03-27 15:53 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-03-22 14:49 [PATCH] fenv fixes for x86_64/i386/ia64 Jakub Jelinek
2007-03-22 21:46 ` Steven Munroe
2007-03-27 15:53   ` Steven Munroe [this message]
     [not found]     ` <20070327160708.GA355@devserv.devel.redhat.com>
2007-03-27 18:07       ` [PATCH] PPC fenv fixes Steven Munroe
2007-03-28 15:29         ` Steven Munroe
2007-04-05  2:27           ` Richard Henderson
2007-04-05 22:00             ` [PATCH] PPC fenv fixes. 3rd update Steven Munroe
2007-04-14 17:32               ` Jakub Jelinek
2007-04-17  0:09                 ` Richard Henderson
     [not found]                   ` <20070417002157.GI355@devserv.devel.redhat.com>
2007-04-30 21:45                     ` Steven Munroe
2007-04-02 16:43       ` [PATCH] [PORTS] PPC fenv fixes for soft-fp Steven Munroe

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=460941B8.2050501@us.ibm.com \
    --to=munroesj@us.ibm.com \
    --cc=drepper@redhat.com \
    --cc=eberlein@us.ibm.com \
    --cc=jakub@redhat.com \
    --cc=libc-hacker@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).