public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
From: Qing Zhao <qing.zhao@oracle.com>
To: Andrew Pinski <pinskia@gmail.com>
Cc: Fangrui Song <maskray@google.com>,
	Richard Biener <richard.guenther@gmail.com>,
	Alexander Monakov <amonakov@ispras.ru>,
	Jeff Law <jeffreyalaw@gmail.com>,
	gcc Patches <gcc-patches@gcc.gnu.org>
Subject: Re: Should -ffp-contract=off the default on GCC?
Date: Fri, 31 Mar 2023 16:31:53 +0000	[thread overview]
Message-ID: <B4B9D4DF-8AA8-4E5A-BB06-014A67CF71CF@oracle.com> (raw)
In-Reply-To: <CA+=Sn1m03WqUGXCPexD4sMf4V-thZDmDkmbz3WZ1sOi-NULE5w@mail.gmail.com>



> On Mar 24, 2023, at 3:42 PM, Andrew Pinski <pinskia@gmail.com> wrote:
> 
> On Fri, Mar 24, 2023 at 1:14 AM Fangrui Song via Gcc-patches
> <gcc-patches@gcc.gnu.org> wrote:
>> 
>> On Wed, Mar 22, 2023 at 8:52 AM Qing Zhao via Gcc-patches
>> <gcc-patches@gcc.gnu.org> wrote:
>>> 
>>> 
>>> 
>>>> On Mar 22, 2023, at 9:57 AM, Richard Biener via Gcc-patches <gcc-patches@gcc.gnu.org> wrote:
>>>> 
>>>> On Wed, Mar 22, 2023 at 1:26 PM Alexander Monakov <amonakov@ispras.ru> wrote:
>>>>> 
>>>>> 
>>>>> On Wed, 22 Mar 2023, Richard Biener wrote:
>>>>> 
>>>>>> I think it's even less realistic to expect users to know the details of
>>>>>> floating-point math.  So I doubt any such sentence will be helpful
>>>>>> besides spreading some FUD?
>>>>> 
>>>>> I think it's closer to "fundamental notions" rather than "details". For
>>>>> users who bother to read the GCC manual there's a decent chance it wouldn't
>>>>> be for naught.
>>>>> 
>>>>> For documentation, I was thinking
>>>>> 
>>>>> Together with -fexcess-precision=standard, -ffp-contract=off
>>>>> is necessary to ensure that rounding of intermediate results to precision
>>>>> implied by the source code and the FLT_EVAL_METHOD macro is not
>>>>> omitted by the compiler.
>>>> 
>>>> that sounds good to me
>>> 
>>> Shall we add such clarification to our Gcc13 doc? That should be helpful if we keep the currently default.
>>> 
>>> Qing
>>>> 
>>>>> Alexander
>>> 
>> 
>> While updating the documentation, consider adding information that
>> #pragma STDC FP_CONTRACT OFF is ignored with -ffp-contract=fast.
>> 
>> This surprising behavior motivated Clang to add
>> -Xclang=-ffp-contract=fast-honor-pragmas
>> (https://discourse.llvm.org/t/fp-contract-fast-and-pragmas/58529).
> 
> `#pragma STDC FP_CONTRACT OFF` is not even implemented yet in GCC.
> Rather we should document that :).

Do we have any plan to implement this pragma?
Also, do we have any plan to implement -ffp-contract=on? 

I am very curious on why -ffp-contract=on has not been implemented for so long time?

There are some documentation on Floating Point implementation of GCC on the pragma STDC FP_CONTRACT
https://gcc.gnu.org/onlinedocs/gcc-12.2.0/gcc/Floating-point-implementation.html#Floating-point-implementation

"
	• Whether and how floating expressions are contracted when not disallowed by the FP_CONTRACT pragma (C99 and C11 6.5).
Expressions are currently only contracted if -ffp-contract=fast, -funsafe-math-optimizations or -ffast-math are used. This is subject to change.

	• The default state for the FP_CONTRACT pragma (C99 and C11 7.12.2).
This pragma is not implemented. Expressions are currently only contracted if -ffp-contract=fast, -funsafe-math-optimizations or -ffast-math are used. This is subject to change.
“

So, looks like that we have documented this. But When the user read the documentation for —ffp-contract option, there is no such information. We might add a link in the documentation of -ffp-contract option to here to make it clear.

Qing




> It does not matter what clang does here really since GCC does not even
> implement the pragma.
> 
> Thanks,
> Andrew Pinski
> 
> 
>> 
>> 
>> 
>> --
>> 宋方睿


  reply	other threads:[~2023-03-31 16:31 UTC|newest]

Thread overview: 32+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-03-16 16:24 Qing Zhao
2023-03-16 16:31 ` Andrew Pinski
2023-03-16 16:38   ` Qing Zhao
2023-03-16 16:53     ` Jakub Jelinek
2023-03-16 18:40       ` Qing Zhao
2023-03-20 22:05       ` Qing Zhao
2023-03-20 22:25         ` Jakub Jelinek
2023-03-21 12:49           ` Qing Zhao
2023-03-21 15:01           ` Qing Zhao
2023-03-21 16:56             ` Paul Koning
2023-03-21 17:00               ` Qing Zhao
2023-03-21 17:59                 ` Jeff Law
2023-03-21 18:03                   ` Paul Koning
2023-03-21 18:55                     ` Toon Moene
2023-03-21 18:12                   ` Alexander Monakov
2023-03-21 18:18                     ` Jeff Law
2023-03-22 10:13                       ` Richard Biener
2023-03-22 12:26                         ` Alexander Monakov
2023-03-22 13:57                           ` Richard Biener
2023-03-22 15:52                             ` Qing Zhao
2023-03-24  7:12                               ` Fangrui Song
2023-03-24 19:42                                 ` Andrew Pinski
2023-03-31 16:31                                   ` Qing Zhao [this message]
2023-03-21 19:01                   ` Qing Zhao
2023-03-21 19:12                     ` Jakub Jelinek
2023-03-21 23:28                       ` Jeff Law
2023-03-21 23:31                         ` Jakub Jelinek
2023-03-21 19:51                     ` Jeff Law
2023-03-21 21:08                       ` Qing Zhao
2023-03-22 12:33           ` Alexander Monakov
2023-03-22 14:33             ` Qing Zhao
2023-03-27  9:03 Zeson

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=B4B9D4DF-8AA8-4E5A-BB06-014A67CF71CF@oracle.com \
    --to=qing.zhao@oracle.com \
    --cc=amonakov@ispras.ru \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=jeffreyalaw@gmail.com \
    --cc=maskray@google.com \
    --cc=pinskia@gmail.com \
    --cc=richard.guenther@gmail.com \
    /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).