public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: "Manuel López-Ibáñez" <lopezibanez@gmail.com>
To: Mathieu Malaterre <malat@debian.org>
Cc: gcc-help <gcc-help@gcc.gnu.org>, Andrew Haley <aph@redhat.com>,
		Markus Trippelsdorf <markus@trippelsdorf.de>
Subject: Re: -ffloat-store behavior (Re: Susprising behavior of gcc on x86 (-m32))
Date: Wed, 09 Sep 2015 09:24:00 -0000	[thread overview]
Message-ID: <CAESRpQDhmKb376CPwqm1-=6S=htE888hxt0xYHd0DrZoibfxog@mail.gmail.com> (raw)
In-Reply-To: <CA+7wUsys_atQyzAcjmO18PouJDpm80sUrwvSAPgKdMDDjAjfjw@mail.gmail.com>

On 9 September 2015 at 09:18, Mathieu Malaterre <malat@debian.org> wrote:
>> Thanks for the link. However -in my case- the compile option
>> `-fexcess-precision=standard` does produce the same code as
>> `-ffloat-store`. At least for
>
> Meant to say `does not produce`

The FAQ now says: "(whether this option has effect or not depends on
other options, please read the manual entry for -fexcess-precision=
carefully)."

The manual says: "-fexcess-precision=standard is not implemented for
languages other than C, and has no effect if
-funsafe-math-optimizations or -ffast-math is specified. On the x86,
it also has no effect if -mfpmath=sse or -mfpmath=sse+387 is
specified; in the former case, IEEE semantics apply without excess
precision, and in the latter, rounding is unpredictable"

>
>> [...]
>> double div; /* OPJ_FLOAT64 */
>> div = dd / dr;
>> if (div >= thresh)
>> [...]
>>
>> Is there a longer description for `-fexcess-precision=standard` which
>> explains case of failures ?

The manual says: "if -fexcess-precision=standard is specified then
excess precision follows the rules specified in ISO C99; in
particular, both casts and assignments cause values to be rounded to
their semantic types (whereas -ffloat-store only affects
assignments)."

The FAQ says: "Floating-point results may still depend on the
optimization level and target architecture in some cases that are
allowed by the ISO C standard. For instance, different sets of
instructions may be used for code such as x*y+z depending on the
target architecture and the optimization level, and this difference
may change the results."

I don't have a list of cases allowed by the standard. If you know more
examples, we could add them to the answer.

> From a clean debian/sid 32bits chroot I can no longer reproduce this.
> In summary:
>
> 1. removed -ffast-math
> 2. add -std=c99
> 3. Change the code for an explicit storage of division (div = dd / dr)
> => issue solved !

The manual says: "This option is enabled by default for C if a strict
conformance option such as -std=c99 is used." Thus, you are in fact
using -fexcess-precision=standard.

That only means that floating-point computations will follow ISO C
rules. FAQ: "Floating-point results may still depend on the
optimization level and target architecture".

Cheers,

Manuel.

  parent reply	other threads:[~2015-09-09  9:24 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-09-08 20:00 Mathieu Malaterre
2015-09-08 20:05 ` Mathieu Malaterre
2015-09-08 21:31   ` Manuel López-Ibáñez
2015-09-09  5:19     ` Markus Trippelsdorf
2015-09-09  6:08     ` Mathieu Malaterre
2015-09-09  7:19       ` Mathieu Malaterre
2015-09-09  8:58         ` Andrew Haley
2015-09-09  9:24         ` Manuel López-Ibáñez [this message]
2015-09-09 13:32           ` Mathieu Malaterre

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='CAESRpQDhmKb376CPwqm1-=6S=htE888hxt0xYHd0DrZoibfxog@mail.gmail.com' \
    --to=lopezibanez@gmail.com \
    --cc=aph@redhat.com \
    --cc=gcc-help@gcc.gnu.org \
    --cc=malat@debian.org \
    --cc=markus@trippelsdorf.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).