]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
re PR c/86420 (nextafter(0x1p-1022,0) is constant folded)
authorJakub Jelinek <jakub@redhat.com>
Mon, 9 Jul 2018 10:56:47 +0000 (12:56 +0200)
committerJakub Jelinek <jakub@gcc.gnu.org>
Mon, 9 Jul 2018 10:56:47 +0000 (12:56 +0200)
PR c/86420
* real.c (real_nextafter): Return true if result is denormal.

* gcc.dg/nextafter-1.c (TEST): Adjust the tests that expect denormals
to be returned and when first argument is not 0, so that they don't do
anything for NEED_EXC or NEED_ERRNO.

From-SVN: r262517

gcc/ChangeLog
gcc/real.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/nextafter-1.c

index 575dff476a412588c7fb7cc17faf769b1fbffc74..e4ecd4cdd27cacf172f3adfc220c23549e9d3981 100644 (file)
@@ -1,3 +1,8 @@
+2018-07-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/86420
+       * real.c (real_nextafter): Return true if result is denormal.
+
 2018-07-09  Martin Liska  <mliska@suse.cz>
 
        * common.opt: Add back wrongly removed attribute.
index eefa69e853573ab34e315172c38a4a561c7a532e..f822ae82d6148d3efaf4533175caf9bb9cf58ccd 100644 (file)
@@ -5141,7 +5141,7 @@ real_nextafter (REAL_VALUE_TYPE *r, format_helper fmt,
       get_zero (r, x->sign);
       return true;
     }
-  return r->cl == rvc_zero;
+  return r->cl == rvc_zero || REAL_EXP (r) < fmt->emin;
 }
 
 /* Write into BUF the maximum representable finite floating-point
index 43b8182feaefa6687e3ee9b77c2468d4c80fdb98..6b51bc6439ef6bd70f2bd0dad54b1c263d14b697 100644 (file)
@@ -1,3 +1,10 @@
+2018-07-09  Jakub Jelinek  <jakub@redhat.com>
+
+       PR c/86420
+       * gcc.dg/nextafter-1.c (TEST): Adjust the tests that expect denormals
+       to be returned and when first argument is not 0, so that they don't do
+       anything for NEED_EXC or NEED_ERRNO.
+
 2018-07-09  Tom de Vries  <tdevries@suse.de>
 
        * gcc.dg/guality/asm-1.c: Use relative line numbers where obvious.
index a768574b3422aeeb8c34dfca63fb1e8f9c22061f..502e0f49b1ee5e2a9a9cd8c58b643c4ae5f3842d 100644 (file)
@@ -58,23 +58,41 @@ name (void)                                                              \
     = (NEED_EXC || NEED_ERRNO) ? __builtin_inf##l1 ()                       \
       : fn (MAX1, __builtin_inf ());                                        \
   CHECK (__builtin_isinf##l1 (m) && !__builtin_signbit (m));                \
-  const type n = fn (DENORM_MIN1, 12.0##L2);                                \
+  const type n                                                              \
+    = (NEED_EXC || NEED_ERRNO) ? 2.0##L1 * DENORM_MIN1                      \
+      : fn (DENORM_MIN1, 12.0##L2);                                         \
   CHECK (n == 2.0##L1 * DENORM_MIN1);                                       \
-  const type o = fn (n, 24.0##L2);                                          \
+  const type o                                                              \
+    = (NEED_EXC || NEED_ERRNO) ? 3.0##L1 * DENORM_MIN1                      \
+      : fn (n, 24.0##L2);                                                   \
   CHECK (o == 3.0##L1 * DENORM_MIN1);                                       \
-  const type p = fn (o, 132.0##L2);                                         \
+  const type p                                                              \
+    = (NEED_EXC || NEED_ERRNO) ? 4.0##L1 * DENORM_MIN1                      \
+      : fn (o, 132.0##L2);                                                  \
   CHECK (p == 4.0##L1 * DENORM_MIN1);                                       \
-  const type q = fn (2.0##L1 * DENORM_MIN1, -__builtin_inf ());                     \
+  const type q                                                              \
+    = (NEED_EXC || NEED_ERRNO) ? DENORM_MIN1                                \
+      : fn (2.0##L1 * DENORM_MIN1, -__builtin_inf ());                      \
   CHECK (q == DENORM_MIN1);                                                 \
-  const type r = fn (3.0##L1 * DENORM_MIN1, DENORM_MIN2);                   \
+  const type r                                                              \
+    = (NEED_EXC || NEED_ERRNO) ? 2.0##L1 * DENORM_MIN1                      \
+      : fn (3.0##L1 * DENORM_MIN1, DENORM_MIN2);                            \
   CHECK (r == 2.0##L1 * DENORM_MIN1);                                       \
-  const type s = fn (4.0##L1 * DENORM_MIN1, 2.0##L2 * DENORM_MIN2);         \
+  const type s                                                              \
+    = (NEED_EXC || NEED_ERRNO) ? 3.0##L1 * DENORM_MIN1                      \
+      : fn (4.0##L1 * DENORM_MIN1, 2.0##L2 * DENORM_MIN2);                  \
   CHECK (s == 3.0##L1 * DENORM_MIN1);                                       \
-  const type t = fn (MIN1, 0.0##L2);                                        \
+  const type t                                                              \
+    = (NEED_EXC || NEED_ERRNO) ? MIN1 - DENORM_MIN1                         \
+      : fn (MIN1, 0.0##L2);                                                 \
   CHECK (t == MIN1 - DENORM_MIN1);                                          \
-  const type u = fn (MIN1 - DENORM_MIN1, -MIN2);                            \
+  const type u                                                              \
+    = (NEED_EXC || NEED_ERRNO) ? MIN1 - 2.0##L1 * DENORM_MIN1               \
+      : fn (MIN1 - DENORM_MIN1, -MIN2);                                             \
   CHECK (u == MIN1 - 2.0##L1 * DENORM_MIN1);                                \
-  const type v = fn (MIN1 - 2.0##L1 * DENORM_MIN1, 100.0##L2);              \
+  const type v                                                              \
+    = (NEED_EXC || NEED_ERRNO) ? MIN1 - DENORM_MIN1                         \
+      : fn (MIN1 - 2.0##L1 * DENORM_MIN1, 100.0##L2);                       \
   CHECK (v == MIN1 - DENORM_MIN1);                                          \
   const type w = fn (MIN1 - DENORM_MIN1, MAX2);                                     \
   CHECK (w == MIN1);                                                        \
@@ -82,9 +100,13 @@ name (void)                                                              \
   CHECK (x == MIN1 + DENORM_MIN1);                                          \
   const type y = fn (MIN1 + DENORM_MIN1, __builtin_inf##l2 ());                     \
   CHECK (y == MIN1 + 2.0##L1 * DENORM_MIN1);                                \
-  const type z = fn (MIN1 / 2.0##L1, -MIN2);                                \
+  const type z                                                              \
+    = (NEED_EXC || NEED_ERRNO) ? MIN1 / 2.0##L1 - DENORM_MIN1               \
+      : fn (MIN1 / 2.0##L1, -MIN2);                                         \
   CHECK (z == MIN1 / 2.0##L1 - DENORM_MIN1);                                \
-  const type aa = fn (-MIN1 / 4.0##L1, MIN2);                               \
+  const type aa                                                                     \
+    = (NEED_EXC || NEED_ERRNO) ? -MIN1 / 4.0##L1 + DENORM_MIN1              \
+      : fn (-MIN1 / 4.0##L1, MIN2);                                         \
   CHECK (aa == -MIN1 / 4.0##L1 + DENORM_MIN1);                              \
   const type ab = fn (MIN1 * 2.0##L1, -MIN2);                               \
   CHECK (ab == MIN1 * 2.0##L1 - DENORM_MIN1);                               \
@@ -92,9 +114,13 @@ name (void)                                                              \
   CHECK (ac == MIN1 * 4.0##L1 - DENORM_MIN1 * 2.0##L1);                             \
   const type ad = fn (MIN1 * 64.0##L1, MIN2);                               \
   CHECK (ad == MIN1 * 64.0##L1 - DENORM_MIN1 * 32.0##L1);                   \
-  const type ae = fn (MIN1 / 2.0##L1 - DENORM_MIN1, 100.0##L2);                     \
+  const type ae                                                                     \
+    = (NEED_EXC || NEED_ERRNO) ? MIN1 / 2.0##L1                                     \
+      : fn (MIN1 / 2.0##L1 - DENORM_MIN1, 100.0##L2);                       \
   CHECK (ae == MIN1 / 2.0##L1);                                                     \
-  const type af = fn (-MIN1 / 4 + DENORM_MIN1, -100.0##L2);                 \
+  const type af                                                                     \
+    = (NEED_EXC || NEED_ERRNO) ? -MIN1 / 4.0##L1                            \
+      : fn (-MIN1 / 4 + DENORM_MIN1, -100.0##L2);                           \
   CHECK (af == -MIN1 / 4.0##L1);                                            \
   const type ag = fn (MIN1 * 2.0##L1 - DENORM_MIN1, 100.0##L2);                     \
   CHECK (ag == MIN1 * 2.0##L1);                                                     \