]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
ibm-ldouble.c (__gcc_qdiv): Scale up arguments in case of small numerator and finite...
authorJoseph Myers <joseph@codesourcery.com>
Fri, 3 Jan 2014 15:54:24 +0000 (15:54 +0000)
committerJoseph Myers <jsm28@gcc.gnu.org>
Fri, 3 Jan 2014 15:54:24 +0000 (15:54 +0000)
libgcc:
* config/rs6000/ibm-ldouble.c (__gcc_qdiv): Scale up arguments in
case of small numerator and finite nonzero result.

gcc/testsuite:
* gcc.target/powerpc/rs6000-ldouble-3.c: New test.

From-SVN: r206321

gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/powerpc/rs6000-ldouble-3.c [new file with mode: 0644]
libgcc/ChangeLog
libgcc/config/rs6000/ibm-ldouble.c

index 7a33757aeff61aa5063b8be4b3b92db2e3d41a70..2f73fb97b5f538c87f8c01d81414b57a1c48d856 100644 (file)
@@ -1,3 +1,7 @@
+2014-01-03  Joseph Myers  <joseph@codesourcery.com>
+
+       * gcc.target/powerpc/rs6000-ldouble-3.c: New test.
+
 2013-12-12  Uros Bizjak  <ubizjak@gmail.com>
 
        Backport from mainline
diff --git a/gcc/testsuite/gcc.target/powerpc/rs6000-ldouble-3.c b/gcc/testsuite/gcc.target/powerpc/rs6000-ldouble-3.c
new file mode 100644 (file)
index 0000000..1c78052
--- /dev/null
@@ -0,0 +1,21 @@
+/* Test accuracy of long double division (glibc bug 15396).  */
+/* { dg-do run { target powerpc*-*-linux* powerpc*-*-darwin* powerpc*-*-aix* rs6000-*-* } } */
+/* { dg-options "-mlong-double-128" } */
+
+extern void exit (int);
+extern void abort (void);
+
+volatile long double a = 0x1p-1024L;
+volatile long double b = 0x3p-53L;
+volatile long double r;
+volatile long double expected = 0x1.55555555555555555555555555p-973L;
+
+int
+main (void)
+{
+  r = a / b;
+  /* Allow error up to 2ulp.  */
+  if (__builtin_fabsl (r - expected) > 0x1p-1073L)
+    abort ();
+  exit (0);
+}
index 53f32383f63d704f9d524b36a2d01a552dc6412a..40fe9fe3821b3a89e21389b0e2229a2b031dd2d9 100644 (file)
@@ -1,3 +1,8 @@
+2014-01-03  Joseph Myers  <joseph@codesourcery.com>
+
+       * config/rs6000/ibm-ldouble.c (__gcc_qdiv): Scale up arguments in
+       case of small numerator and finite nonzero result.
+
 2013-11-10  Kai Tietz  <ktietz@redhat.com>
 
        Back-merged from trunk
index b0b8037cdcecd7b870ec388cb1aaae23b478cda6..658ca9adea79c3e62d3f86261a2df44536215a72 100644 (file)
@@ -189,7 +189,16 @@ __gcc_qdiv (double a, double b, double c, double d)
       || nonfinite (t))
     return t;
 
-  /* Finite nonzero result requires corrections to the highest order term.  */
+  /* Finite nonzero result requires corrections to the highest order
+     term.  These corrections require the low part of c * t to be
+     exactly represented in double.  */
+  if (fabs (a) <= 0x1p-969)
+    {
+      a *= 0x1p106;
+      b *= 0x1p106;
+      c *= 0x1p106;
+      d *= 0x1p106;
+    }
 
   s = c * t;                    /* (s,sigma) = c*t exactly.  */
   w = -(-b + d * t);   /* Written to get fnmsub for speed, but not