diff mbox

[PR,57363] IBM long double: adding qNaN and number raises inexact exception

Message ID 528CC307.90804@linux.vnet.ibm.com
State New
Headers show

Commit Message

Adhemerval Zanella Nov. 20, 2013, 2:11 p.m. UTC
Hi,

This is a reformatted patch after Ulrich review:

---

libgcc/ChangeLog:

2013-11-20  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>

	* config/rs6000/ibm-ldouble.c (__gcc_qadd): Fix add
 	of normal number and qNaN to not raise an inexact exception.

gcc/testsuite/ChangeLog:

2013-11-20  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>

	* gcc.target/powerpc/pr57363.c: New test.

--

Comments

David Edelsohn Nov. 20, 2013, 4:23 p.m. UTC | #1
On Wed, Nov 20, 2013 at 9:11 AM, Adhemerval Zanella
<azanella@linux.vnet.ibm.com> wrote:

> libgcc/ChangeLog:
>
> 2013-11-20  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
>
>         * config/rs6000/ibm-ldouble.c (__gcc_qadd): Fix add
>         of normal number and qNaN to not raise an inexact exception.
>
> gcc/testsuite/ChangeLog:
>
> 2013-11-20  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
>
>         * gcc.target/powerpc/pr57363.c: New test.

This is okay.  And the patch is small enough that it does not need a
copyright assignment for GCC.

Do you need someone to commit the patch for you?

Thanks, David
Adhemerval Zanella Nov. 20, 2013, 6:32 p.m. UTC | #2
On 20-11-2013 14:23, David Edelsohn wrote:
> On Wed, Nov 20, 2013 at 9:11 AM, Adhemerval Zanella
> <azanella@linux.vnet.ibm.com> wrote:
>
>> libgcc/ChangeLog:
>>
>> 2013-11-20  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
>>
>>         * config/rs6000/ibm-ldouble.c (__gcc_qadd): Fix add
>>         of normal number and qNaN to not raise an inexact exception.
>>
>> gcc/testsuite/ChangeLog:
>>
>> 2013-11-20  Adhemerval Zanella  <azanella@linux.vnet.ibm.com>
>>
>>         * gcc.target/powerpc/pr57363.c: New test.
> This is okay.  And the patch is small enough that it does not need a
> copyright assignment for GCC.
>
> Do you need someone to commit the patch for you?
>
> Thanks, David
>
Yes I do need, thanks.
Joseph Myers Jan. 2, 2014, 8:26 p.m. UTC | #3
I'd like to suggest applying this to active GCC release branches (i.e. 4.8 
and 4.7), subject to testing there, as (effectively) a wrong-code bug fix 
needed to avoid glibc test failures.
diff mbox

Patch

diff --git a/gcc/testsuite/gcc.target/powerpc/pr57363.c b/gcc/testsuite/gcc.target/powerpc/pr57363.c
new file mode 100644
index 0000000..45ea3f3
--- /dev/null
+++ b/gcc/testsuite/gcc.target/powerpc/pr57363.c
@@ -0,0 +1,19 @@ 
+/* { dg-do run { target { powerpc*-*-linux* } } } */
+/* { dg-options "-mlong-double-128" } */
+
+/* Check if adding a qNAN and a normal long double does not generate a
+   inexact exception.  */
+
+#define _GNU_SOURCE
+#include <fenv.h>
+
+int main(void)
+{
+  double x = __builtin_nan ("");
+  long double y = 1.1L;
+
+  feenableexcept (FE_INEXACT);
+  feclearexcept (FE_ALL_EXCEPT);
+  x = x + y;
+  return fetestexcept(FE_INEXACT);
+}
diff --git a/libgcc/config/rs6000/ibm-ldouble.c b/libgcc/config/rs6000/ibm-ldouble.c
index 28e02e9..7ca900c 100644
--- a/libgcc/config/rs6000/ibm-ldouble.c
+++ b/libgcc/config/rs6000/ibm-ldouble.c
@@ -104,6 +104,8 @@  __gcc_qadd (double a, double aa, double c, double cc)
 
   if (nonfinite (z))
     {
+      if (fabs (z) != inf())
+	return z;
       z = cc + aa + c + a;
       if (nonfinite (z))
 	return z;