linux-mips
[Top] [All Lists]

Re: [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands

To: Atsushi Nemoto <anemo@mba.ocn.ne.jp>
Subject: Re: [PATCH] Fix abs.[sd] and neg.[sd] emulation for NaN operands
From: Chris Dearman <chris@mips.com>
Date: Mon, 10 May 2010 11:37:10 -0700
Cc: linux-mips@linux-mips.org
In-reply-to: <20100510.234946.229279777.anemo@mba.ocn.ne.jp>
Organization: MIPS Technologies
Original-recipient: rfc822;linux-mips@linux-mips.org
References: <20091012215522.30362.49399.stgit@localhost.localdomain> <20091012215718.30362.67068.stgit@localhost.localdomain> <20100510.234946.229279777.anemo@mba.ocn.ne.jp>
Sender: linux-mips-bounce@linux-mips.org
User-agent: Thunderbird 2.0.0.24 (X11/20100411)
Atsushi Nemoto wrote:
Excuse me for too late comment.

On Mon, 12 Oct 2009 14:57:18 -0700, Chris Dearman <chris@mips.com> wrote:
From: Nigel Stephens <nigel@mips.com>

This patch ensures that the sign bit is always updated
for NaN operands.
...
@@ -76,15 +74,12 @@ ieee754dp ieee754dp_abs(ieee754dp x)
        CLEARCX;
        FLUSHXDP;
+ /* Clear sign ALWAYS, irrespective of NaN */
+       DPSIGN(x) = 0;
+
        if (xc == IEEE754_CLASS_SNAN) {
-               SETCX(IEEE754_INVALID_OPERATION);
-               return ieee754dp_nanxcpt(ieee754dp_indef(), "neg");
+               return ieee754dp_nanxcpt(ieee754dp_indef(), "abs");
        }
- if (ieee754dp_isnan(x)) /* but not infinity */
-               return ieee754dp_nanxcpt(x, "abs", x);
-
-       /* quick fix up */
-       DPSIGN(x) = 0;
        return x;
 }

Is there any reason for removal of SETCX(IEEE754_INVALID_OPERATION)
line here?

The older version of this fix ("Fix absd emulation" by Raghu Gandham)
did not remove the line.

Without this line, a signaling NaN will not raise a signal.  It seems
not expected behaviour.

ieee754dp/sp_nanxcpt also sets the invalid exception bit so I think this is duplicated code. I think the same fix should have been applied to ieee754sp_neg/ieee754dp_neg for consistency.

Chris

--
Chris Dearman               Desk: +1 408 530 5092  Cell: +1 408 398 5531
MIPS Technologies Inc            955 East Arques Ave, Sunnyvale CA 94085

<Prev in Thread] Current Thread [Next in Thread>