From b03fb8c9964613f37a05713ee03f4986c1565fb5 Mon Sep 17 00:00:00 2001 From: Adhemerval Zanella Date: Tue, 3 Dec 2013 18:57:37 +0000 Subject: [PATCH] ibm-ldouble.c (__gcc_qadd): Fix add of normal number and qNaN to not raise an inexact exception. libgcc/ChangeLog: 2013-12-03 Adhemerval Zanella * config/rs6000/ibm-ldouble.c (__gcc_qadd): Fix add of normal number and qNaN to not raise an inexact exception. gcc/testsuite/ChangeLog: 2013-12-03 Adhemerval Zanella * gcc.target/powerpc/pr57363.c: New test. From-SVN: r205645 --- gcc/testsuite/ChangeLog | 4 ++++ gcc/testsuite/gcc.target/powerpc/pr57363.c | 19 +++++++++++++++++++ libgcc/ChangeLog | 5 +++++ libgcc/config/rs6000/ibm-ldouble.c | 2 ++ 4 files changed, 30 insertions(+) create mode 100644 gcc/testsuite/gcc.target/powerpc/pr57363.c diff --git a/gcc/testsuite/ChangeLog b/gcc/testsuite/ChangeLog index c1a0f54f093d..2fea78d97d00 100644 --- a/gcc/testsuite/ChangeLog +++ b/gcc/testsuite/ChangeLog @@ -1,3 +1,7 @@ +2013-12-03 Adhemerval Zanella + + * gcc.target/powerpc/pr57363.c: New test. + 2013-12-03 Wei Mi PR rtl-optimization/59020 diff --git a/gcc/testsuite/gcc.target/powerpc/pr57363.c b/gcc/testsuite/gcc.target/powerpc/pr57363.c new file mode 100644 index 000000000000..45ea3f3fe61b --- /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 + +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/ChangeLog b/libgcc/ChangeLog index 32705bf1709a..fea1c054766b 100644 --- a/libgcc/ChangeLog +++ b/libgcc/ChangeLog @@ -1,3 +1,8 @@ +2013-12-03 Adhemerval Zanella + + * config/rs6000/ibm-ldouble.c (__gcc_qadd): Fix add + of normal number and qNaN to not raise an inexact exception. + 2013-11-28 Uros Bizjak * config/i386/32/sfp-machine.h (__FP_FRAC_ADDI_4): New macro. diff --git a/libgcc/config/rs6000/ibm-ldouble.c b/libgcc/config/rs6000/ibm-ldouble.c index 28e02e995d4a..7ca900c78300 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; -- 2.47.3