all messages for Guix-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Michael Schierl <schierlm@gmx.de>
To: Andreas Enge <andreas@enge.fr>
Cc: guix-devel@gnu.org
Subject: Re: Procps in core-updates
Date: Sun, 19 Mar 2023 18:36:09 +0100	[thread overview]
Message-ID: <e4211dc8-d94d-d612-a229-a0b04c6e4b8a@gmx.de> (raw)
In-Reply-To: <ZBWve8oVF1s6NDav@jurong>

Hello Andreas,


Am 18.03.2023 um 13:32 schrieb Andreas Enge:

> Has anyone got any explanation for this behaviour? A compiler error?

Nasal daemons are not a compiler error.

Anyway, getting an assembly listing from your gcc version (using the -S
switch) would reduce the guesswork. Pass the same compiler flags as the
test does. In particular, various options of "-fexcess-precision" flag
may alter the generated assembly code and the test outcome.

> but this is not even floating point maths - whatever the contents of val
> and tests[i].result, they should not be changed by a comparison (or an
> fprintf; I can also make the test work just by adding some printf into
> the strtod_nol_or_err function that is exercised by this test).

Wild guess:

At the first printf, GCC knows that val still resides in some floating
point register of your CPU (be it SSE, MMX or x87 registers, depending
on the processor models your gcc targets).

Hardware floating point registers on x86 are a mess, and they usually do
not have the same precision as the IEEE floating point values that are
stored in variables (e.g. on the stack or heap), but are slightly more
precise.

So, at your first printf, gcc will create code that compares that
floating point register to the value in the array (loaded into another
floating point register of the same type).

As the function call will likely clobber some floating point registers
(depending on calling convention), for the second printf, gcc will have
to create code that loads the value from stack (with reduced precision)
back into the floating point register, reducing the precision of the
value and making it equal again.

Adding "asm volatile" barriers with matching clobbers flags (tbh I don't
know by heart what clobbers flags you need to pass to mark *any* x86
floating point registers as clobbered) should also make the nasal
deamons disappear, in case tweaking the compiler flags is not an option.


Regards,


Michael



  parent reply	other threads:[~2023-03-19 17:36 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-18 12:32 Procps in core-updates Andreas Enge
2023-03-18 17:38 ` Leo Famulari
2023-03-18 17:44   ` Andreas Enge
2023-03-19 17:36 ` Michael Schierl [this message]
2023-03-20 14:54   ` Andreas Enge
2023-03-20 20:02     ` Michael Schierl
2023-03-20 21:25       ` Andreas Enge
2023-03-19 17:49 ` Felix Lechner via Development of GNU Guix and the GNU System distribution.
2023-03-19 19:22   ` Kaelyn

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

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

  git send-email \
    --in-reply-to=e4211dc8-d94d-d612-a229-a0b04c6e4b8a@gmx.de \
    --to=schierlm@gmx.de \
    --cc=andreas@enge.fr \
    --cc=guix-devel@gnu.org \
    /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.
Code repositories for project(s) associated with this external index

	https://git.savannah.gnu.org/cgit/guix.git

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.