bug-gnulib@gnu.org mirror (unofficial)
 help / color / mirror / Atom feed
From: Bruno Haible <bruno@clisp.org>
To: "Tim Rühsen" <tim.ruehsen@gmx.de>
Cc: bug-gnulib@gnu.org
Subject: Fix exponentl.m4 test
Date: Sat, 23 May 2020 19:51:22 +0200	[thread overview]
Message-ID: <5683048.9VKiI42e5V@omega> (raw)
In-Reply-To: <ce37c266-64e4-2822-659e-c808968816d3@gmx.de>

Tim Rühsen wrote:
> Attached is the config.log and config.cache for
> - gcc-9 with unset CFLAGS (*.gcc-9)
> - clang-9 with unset CFLAGS (*.clang-9)
> - gcc-10 with unset CFLAGS (*.gcc-10)
> - clang-10 with unset CFLAGS (*.clang-10)
> 
> And the same set with -fsanitize... (*.sanitize).

Thanks, that's much more useful.

The first interesting finding is this difference between config.cache.gcc-9
and config.cache.gcc-10:

-gl_cv_cc_long_double_expbit0=${gl_cv_cc_long_double_expbit0='word 2 bit 0'}
+gl_cv_cc_long_double_expbit0=${gl_cv_cc_long_double_expbit0=unknown}

Indeed, with GCC 10 I see:

  checking where to find the exponent in a 'long double'... unknown

I see it also with older versions of GCC, with "-O2".

What happens is that on x86_64, 'long double' is the 80-bit "extended double"
format, which needs 3 'unsigned int' values. But sizeof (long double) = 16
[whereas on x86, sizeof (long double) = 12]. So, in the test, NWORDS = 4.
But when optimizing, the compiler apparently copies only 3 words, not 4 words,
when reading or writing a parameter of type 'long double'.

I would like to avoid hard coding the particular representation (since
possible some other compilers will use 'float128' as 'long double').

This patch brings back

  checking where to find the exponent in a 'long double'... word 2 bit 0


2020-05-23  Bruno Haible  <bruno@clisp.org>

	isnanl, isnanl-nolibm: Make a test work better with "gcc -O2" on x86_64.
	* m4/exponentl.m4 (gl_LONG_DOUBLE_EXPONENT_LOCATION): Pass the
	'long double' values by reference, with values taken from a statically
	allocated array.

diff --git a/m4/exponentl.m4 b/m4/exponentl.m4
index b33b3bf..0a35c11 100644
--- a/m4/exponentl.m4
+++ b/m4/exponentl.m4
@@ -1,4 +1,4 @@
-# exponentl.m4 serial 4
+# exponentl.m4 serial 5
 dnl Copyright (C) 2007-2020 Free Software Foundation, Inc.
 dnl This file is free software; the Free Software Foundation
 dnl gives unlimited permission to copy and/or distribute it,
@@ -22,14 +22,14 @@ typedef union { long double value; unsigned int word[NWORDS]; }
         memory_long_double;
 static unsigned int ored_words[NWORDS];
 static unsigned int anded_words[NWORDS];
-static void add_to_ored_words (long double x)
+static void add_to_ored_words (long double *x)
 {
   memory_long_double m;
   size_t i;
   /* Clear it first, in case
      sizeof (long double) < sizeof (memory_long_double).  */
   memset (&m, 0, sizeof (memory_long_double));
-  m.value = x;
+  m.value = *x;
   for (i = 0; i < NWORDS; i++)
     {
       ored_words[i] |= m.word[i];
@@ -38,17 +38,15 @@ static void add_to_ored_words (long double x)
 }
 int main ()
 {
+  static long double samples[5] = { 0.25L, 0.5L, 1.0L, 2.0L, 4.0L };
   size_t j;
   FILE *fp = fopen ("conftest.out", "w");
   if (fp == NULL)
     return 1;
   for (j = 0; j < NWORDS; j++)
     anded_words[j] = ~ (unsigned int) 0;
-  add_to_ored_words (0.25L);
-  add_to_ored_words (0.5L);
-  add_to_ored_words (1.0L);
-  add_to_ored_words (2.0L);
-  add_to_ored_words (4.0L);
+  for (j = 0; j < 5; j++)
+    add_to_ored_words (&samples[j]);
   /* Remove bits that are common (e.g. if representation of the first mantissa
      bit is explicit).  */
   for (j = 0; j < NWORDS; j++)



  reply	other threads:[~2020-05-23 17:51 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-18 10:43 Fix memleak in getdelim.m4 Tim Rühsen
2020-05-18 11:50 ` Bruno Haible
2020-05-18 18:21   ` Tim Rühsen
2020-05-18 19:44     ` Bruno Haible
2020-05-19 21:47       ` Tim Rühsen
2020-05-19 22:46         ` Bruno Haible
2020-05-20 18:45           ` Tim Rühsen
2020-05-21 14:22             ` relicense module 'group-member' Bruno Haible
2020-05-21 14:44               ` Eric Blake
2020-05-21 15:10                 ` Jim Meyering
2020-05-21 19:46                   ` Bruno Haible
2020-05-21 19:27               ` Paul Eggert
2020-05-21 14:23             ` Fix memleak in getdelim.m4 Bruno Haible
2020-05-20 21:59       ` Tim Rühsen
2020-05-21 14:26         ` Bruno Haible
2020-05-21 16:11           ` Tim Rühsen
2020-05-21 19:31             ` Bruno Haible
2020-05-22 14:03               ` Tim Rühsen
2020-05-22 15:25                 ` Bruno Haible
2020-05-22 20:46                   ` Tim Rühsen
2020-05-23 17:51                     ` Bruno Haible [this message]
2020-05-23 18:48                     ` Fix calloc.m4 test Bruno Haible
2020-05-23 20:26                       ` Paul Eggert
2020-05-23 21:53                         ` Bruno Haible
2020-05-24  0:51                           ` Paul Eggert
2020-05-24  7:53                             ` Bruno Haible
2020-06-06  8:19                       ` Bruno Haible
2020-05-23 19:18                     ` Fix invalid use of __builtin_isnanf and __builtin_isnanl Bruno Haible
2020-05-23 20:18                     ` Fix calloc-gnu configure results Bruno Haible
2020-05-23 20:47                     ` Fix memleak in getdelim.m4 Bruno Haible
2020-05-24  8:39                       ` Tim Rühsen
2020-05-21 15:15         ` SA_RESETHAND Bruno Haible
2020-05-21 20:10           ` SA_RESETHAND Paul Eggert
2020-05-21 20:59             ` SA_RESETHAND Bruno Haible
2020-05-21 15:22         ` Fix sanitizer error in fchownat.m4 Bruno Haible
2020-05-21 17:42         ` Fix memleak in glob.m4 Bruno Haible
2020-05-21 18:31         ` Fix memleak in regex.m4 Bruno Haible
2020-05-21 18:40         ` Fix memleak in getdelim.m4 Bruno Haible
2020-05-21 19:30           ` Paul Eggert
2020-05-21 19:38             ` Bruno Haible
2020-05-21 14:32 ` Bruno Haible

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://lists.gnu.org/mailman/listinfo/bug-gnulib

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5683048.9VKiI42e5V@omega \
    --to=bruno@clisp.org \
    --cc=bug-gnulib@gnu.org \
    --cc=tim.ruehsen@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).