public inbox for gcc-patches@gcc.gnu.org
 help / color / mirror / Atom feed
* [wwwdocs] gcc-13/changes.html: Document C++ -fexcess-precision=standard
@ 2023-02-09 16:20 Jakub Jelinek
  2023-02-10  9:06 ` Gerald Pfeifer
  0 siblings, 1 reply; 8+ messages in thread
From: Jakub Jelinek @ 2023-02-09 16:20 UTC (permalink / raw)
  To: gcc-patches, Gerald Pfeifer

Hi!

Martin Liska mentioned that porting_to.html doesn't mention
the C++ excess precision changes.  Not really sure if porting_to
should document those, but I think changes.html certainly should.
And perhaps porting_to could have some examples and link to this
spot in changes.

Ok for wwwdocs?

--- a/htdocs/gcc-13/changes.html
+++ b/htdocs/gcc-13/changes.html
@@ -230,6 +230,21 @@ a work-in-progress.</p>
 
 <h3 id="cxx">C++</h3>
 <ul>
+  <li>Excess precision support (which has been available in C since GCC 4.5)
+      has been implemented for C++ as well.  It is enabled by default
+      in strict standard modes like <code>-std=c++17</code>, where it
+      defaults to <code>-fexcess-precision=standard</code>, while in GNU
+      standard modes like <code>-std=gnu++20</code> it defaults to
+      <code>-fexcess-precision=fast</code>.  The option affects mainly
+      IA-32/x86-64 where when defaulting to x87 math and in some cases on
+      Motorola 68000 <code>float</code> and <code>double</code> expressions
+      are evaluated in <code>long double</code> precision and S/390, System z,
+      IBM z Systems where <code>float</code> expressions are evaluated in
+      <code>double</code> precision.  Also, on several architectures where
+      <code>std::float16_t</code> or <code>std::bfloat16_t</code> types
+      are supported those are evaluated in <code>float</code> precision.
+      <code>-fexcess-precision=fast</code> restores previous behavior.
+  </li>
   <li>Several C++23 features have been implemented:
     <ul>
       <li><a href="https://wg21.link/p2324">P2324R1</a>, Labels at the end of

	Jakub


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [wwwdocs] gcc-13/changes.html: Document C++ -fexcess-precision=standard
  2023-02-09 16:20 [wwwdocs] gcc-13/changes.html: Document C++ -fexcess-precision=standard Jakub Jelinek
@ 2023-02-10  9:06 ` Gerald Pfeifer
  2023-03-02 10:32   ` [wwwdocs] gcc-13/porting_to.html: " Jakub Jelinek
  0 siblings, 1 reply; 8+ messages in thread
From: Gerald Pfeifer @ 2023-02-10  9:06 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: gcc-patches

On Thu, 9 Feb 2023, Jakub Jelinek wrote:
> Martin Liska mentioned that porting_to.html doesn't mention
> the C++ excess precision changes.  Not really sure if porting_to
> should document those, but I think changes.html certainly should.

Do you think this is a widely spread issue for existing software? Did 
it materialize a couple of times building/testing Fedora with GCC 13 
snapshots (assuming you have done so as in the past)?

> Ok for wwwdocs?

Yes, thank you! Two minor suggestions/questions below:

> --- a/htdocs/gcc-13/changes.html
> +++ b/htdocs/gcc-13/changes.html
> +      <code>-fexcess-precision=fast</code>.  The option affects mainly

Here I'd say "mainly affects".

> +      IA-32/x86-64 where when defaulting to x87 math and in some cases on
> +      Motorola 68000 <code>float</code> and <code>double</code> expressions
> +      are evaluated in <code>long double</code> precision and S/390, System z,
> +      IBM z Systems where <code>float</code> expressions are evaluated in
> +      <code>double</code> precision.

The "where when" part proved a bit tricky for my brain. :-) 

I think it is precise, but am wondering whether

  ...IA-32/x64 using x87 math and in some cases on Motorola 68000, where
  <code>float</code> and <code>double</code> expressions are evaluated...

might work? What do you think?

Gerald

^ permalink raw reply	[flat|nested] 8+ messages in thread

* [wwwdocs] gcc-13/porting_to.html: Document C++ -fexcess-precision=standard
  2023-02-10  9:06 ` Gerald Pfeifer
@ 2023-03-02 10:32   ` Jakub Jelinek
  2023-03-02 12:40     ` Martin Liška
                       ` (2 more replies)
  0 siblings, 3 replies; 8+ messages in thread
From: Jakub Jelinek @ 2023-03-02 10:32 UTC (permalink / raw)
  To: Gerald Pfeifer, Martin Liška; +Cc: gcc-patches

Hi!

On Fri, Feb 10, 2023 at 10:06:03AM +0100, Gerald Pfeifer wrote:
> Yes, thank you! Two minor suggestions/questions below:
> 
> > --- a/htdocs/gcc-13/changes.html
> > +++ b/htdocs/gcc-13/changes.html
> > +      <code>-fexcess-precision=fast</code>.  The option affects mainly
> 
> Here I'd say "mainly affects".
> 
> > +      IA-32/x86-64 where when defaulting to x87 math and in some cases on
> > +      Motorola 68000 <code>float</code> and <code>double</code> expressions
> > +      are evaluated in <code>long double</code> precision and S/390, System z,
> > +      IBM z Systems where <code>float</code> expressions are evaluated in
> > +      <code>double</code> precision.
> 
> The "where when" part proved a bit tricky for my brain. :-) 
> 
> I think it is precise, but am wondering whether
> 
>   ...IA-32/x64 using x87 math and in some cases on Motorola 68000, where
>   <code>float</code> and <code>double</code> expressions are evaluated...
> 
> might work? What do you think?

Thanks, committed with those tweaks.

Martin would like to see some note in porting_to.html for it too,
here is my attempt to do so:

diff --git a/htdocs/gcc-13/porting_to.html b/htdocs/gcc-13/porting_to.html
index 9a9a3147..5cbeefb6 100644
--- a/htdocs/gcc-13/porting_to.html
+++ b/htdocs/gcc-13/porting_to.html
@@ -120,5 +120,29 @@ the operand as an lvalue.<br>
    }
 </code></pre>
 
+<h3 id="excess-precision">Excess precision changes</h3>
+<p>GCC 13 implements in C++ <a href="changes.html#cxx">excess precision support</a>
+which has been implemented just in the C front-end before.  The new behavior is
+enabled by default in <code>-std=c++</code><em>NN</em> modes and when
+<code>FLT_EVAL_METHOD</code> is 1 or 2 affects behavior of floating point
+constants and expressions.  E.g. for <code>FLT_EVAL_METHOD</code> equal
+to 2 on ia32:
+
+<pre><code>
+#include <stdlib.h>
+void foo (void) { if (1.1f + 3.3f != 1.1L + 3.3L) abort (); }
+void bar (void) { double d = 4.2; if (d == 4.2) abort (); }
+</code></pre>
+
+will not abort with standard excess precision, because constants and expressions
+in <code>float</code> or <code>double</code> are evaluated in precision of
+<code>long double</code> and demoted only on casts or assignments, but will
+abort with fast excess precision, where whether something is evaluated in
+precision of <code>long double</code> or not depends on what evaluations are
+done in the i387 floating point stack or are spilled from it.
+
+The <code>-fexcess-precision=fast</code> option can be used to request the
+previous behavior.
+
 </body>
 </html>


	Jakub


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [wwwdocs] gcc-13/porting_to.html: Document C++ -fexcess-precision=standard
  2023-03-02 10:32   ` [wwwdocs] gcc-13/porting_to.html: " Jakub Jelinek
@ 2023-03-02 12:40     ` Martin Liška
  2023-03-02 23:05     ` Gerald Pfeifer
  2023-03-09  7:09     ` Gerald Pfeifer
  2 siblings, 0 replies; 8+ messages in thread
From: Martin Liška @ 2023-03-02 12:40 UTC (permalink / raw)
  To: Jakub Jelinek, Gerald Pfeifer; +Cc: gcc-patches

On 3/2/23 11:32, Jakub Jelinek wrote:
> Hi!
> 
> On Fri, Feb 10, 2023 at 10:06:03AM +0100, Gerald Pfeifer wrote:
>> Yes, thank you! Two minor suggestions/questions below:
>>
>>> --- a/htdocs/gcc-13/changes.html
>>> +++ b/htdocs/gcc-13/changes.html
>>> +      <code>-fexcess-precision=fast</code>.  The option affects mainly
>>
>> Here I'd say "mainly affects".
>>
>>> +      IA-32/x86-64 where when defaulting to x87 math and in some cases on
>>> +      Motorola 68000 <code>float</code> and <code>double</code> expressions
>>> +      are evaluated in <code>long double</code> precision and S/390, System z,
>>> +      IBM z Systems where <code>float</code> expressions are evaluated in
>>> +      <code>double</code> precision.
>>
>> The "where when" part proved a bit tricky for my brain. :-) 
>>
>> I think it is precise, but am wondering whether
>>
>>   ...IA-32/x64 using x87 math and in some cases on Motorola 68000, where
>>   <code>float</code> and <code>double</code> expressions are evaluated...
>>
>> might work? What do you think?
> 
> Thanks, committed with those tweaks.
> 
> Martin would like to see some note in porting_to.html for it too,
> here is my attempt to do so:

I like the suggested wording. Thanks for it.

Martin

> 
> diff --git a/htdocs/gcc-13/porting_to.html b/htdocs/gcc-13/porting_to.html
> index 9a9a3147..5cbeefb6 100644
> --- a/htdocs/gcc-13/porting_to.html
> +++ b/htdocs/gcc-13/porting_to.html
> @@ -120,5 +120,29 @@ the operand as an lvalue.<br>
>     }
>  </code></pre>
>  
> +<h3 id="excess-precision">Excess precision changes</h3>
> +<p>GCC 13 implements in C++ <a href="changes.html#cxx">excess precision support</a>
> +which has been implemented just in the C front-end before.  The new behavior is
> +enabled by default in <code>-std=c++</code><em>NN</em> modes and when
> +<code>FLT_EVAL_METHOD</code> is 1 or 2 affects behavior of floating point
> +constants and expressions.  E.g. for <code>FLT_EVAL_METHOD</code> equal
> +to 2 on ia32:
> +
> +<pre><code>
> +#include <stdlib.h>
> +void foo (void) { if (1.1f + 3.3f != 1.1L + 3.3L) abort (); }
> +void bar (void) { double d = 4.2; if (d == 4.2) abort (); }
> +</code></pre>
> +
> +will not abort with standard excess precision, because constants and expressions
> +in <code>float</code> or <code>double</code> are evaluated in precision of
> +<code>long double</code> and demoted only on casts or assignments, but will
> +abort with fast excess precision, where whether something is evaluated in
> +precision of <code>long double</code> or not depends on what evaluations are
> +done in the i387 floating point stack or are spilled from it.
> +
> +The <code>-fexcess-precision=fast</code> option can be used to request the
> +previous behavior.
> +
>  </body>
>  </html>
> 
> 
> 	Jakub
> 


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [wwwdocs] gcc-13/porting_to.html: Document C++ -fexcess-precision=standard
  2023-03-02 10:32   ` [wwwdocs] gcc-13/porting_to.html: " Jakub Jelinek
  2023-03-02 12:40     ` Martin Liška
@ 2023-03-02 23:05     ` Gerald Pfeifer
  2023-03-02 23:16       ` Jakub Jelinek
  2023-03-09  7:09     ` Gerald Pfeifer
  2 siblings, 1 reply; 8+ messages in thread
From: Gerald Pfeifer @ 2023-03-02 23:05 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Martin Liška, gcc-patches

On Thu, 2 Mar 2023, Jakub Jelinek wrote:
> +<pre><code>
> +#include <stdlib.h>

Oops, in HTML we need to spell "<" as "&lt;" and ">" as "&gt; - otherwise
the above would be seen as a tag by the name of stdlib.h. ;-)

I pushed the follow-up patch below.

Gerald


commit 935fcdebfb2fb4dcd89edb51ebed5f1be0fb41e5
Author: Gerald Pfeifer <gerald@pfeifer.com>
Date:   Thu Mar 2 23:58:29 2023 +0100

    gcc-13: Use &lt; and &gt; where necessary

diff --git a/htdocs/gcc-13/porting_to.html b/htdocs/gcc-13/porting_to.html
index f0ccef69..953e1453 100644
--- a/htdocs/gcc-13/porting_to.html
+++ b/htdocs/gcc-13/porting_to.html
@@ -129,7 +129,7 @@ constants and expressions.  E.g. for <code>FLT_EVAL_METHOD</code> equal
 to 2 on ia32:
 
 <pre><code>
-#include <stdlib.h>
+#include &lt;stdlib.h&gt;
 void foo (void) { if (1.1f + 3.3f != 1.1L + 3.3L) abort (); }
 void bar (void) { double d = 4.2; if (d == 4.2) abort (); }
 </code></pre>

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [wwwdocs] gcc-13/porting_to.html: Document C++ -fexcess-precision=standard
  2023-03-02 23:05     ` Gerald Pfeifer
@ 2023-03-02 23:16       ` Jakub Jelinek
  0 siblings, 0 replies; 8+ messages in thread
From: Jakub Jelinek @ 2023-03-02 23:16 UTC (permalink / raw)
  To: Gerald Pfeifer; +Cc: Martin Liška, gcc-patches

On Fri, Mar 03, 2023 at 12:05:09AM +0100, Gerald Pfeifer wrote:
> On Thu, 2 Mar 2023, Jakub Jelinek wrote:
> > +<pre><code>
> > +#include <stdlib.h>
> 
> Oops, in HTML we need to spell "<" as "&lt;" and ">" as "&gt; - otherwise
> the above would be seen as a tag by the name of stdlib.h. ;-)
> 
> I pushed the follow-up patch below.

Oops, missed that.  Thanks.

	Jakub


^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [wwwdocs] gcc-13/porting_to.html: Document C++ -fexcess-precision=standard
  2023-03-02 10:32   ` [wwwdocs] gcc-13/porting_to.html: " Jakub Jelinek
  2023-03-02 12:40     ` Martin Liška
  2023-03-02 23:05     ` Gerald Pfeifer
@ 2023-03-09  7:09     ` Gerald Pfeifer
  2023-03-09  8:05       ` Jakub Jelinek
  2 siblings, 1 reply; 8+ messages in thread
From: Gerald Pfeifer @ 2023-03-09  7:09 UTC (permalink / raw)
  To: Jakub Jelinek; +Cc: Martin Liška, gcc-patches

On Thu, 2 Mar 2023, Jakub Jelinek wrote:
> --- a/htdocs/gcc-13/porting_to.html
> +++ b/htdocs/gcc-13/porting_to.html

> +<p>GCC 13 implements in C++ <a href="changes.html#cxx">excess precision support</a>
> +which has been implemented just in the C front-end before.  The new behavior is
> +enabled by default in <code>-std=c++</code><em>NN</em> modes and when
> +<code>FLT_EVAL_METHOD</code> is 1 or 2 affects behavior of floating point
                                               ^^^^^^
> +constants and expressions.  E.g. for <code>FLT_EVAL_METHOD</code> equal
> +to 2 on ia32:

:

> +will not abort with standard excess precision, because constants and expressions
> +in <code>float</code> or <code>double</code> are evaluated in precision of
> +<code>long double</code> and demoted only on casts or assignments, but will
> +abort with fast excess precision, where whether something is evaluated in
> +precision of <code>long double</code> or not depends on what evaluations are
> +done in the i387 floating point stack or are spilled from it.
> +
> +The <code>-fexcess-precision=fast</code> option can be used to request the
> +previous behavior.

I struggled a bit understanding this and so have come up with what I 
hope is simpler (without changing the meaning).

What do you think of the change below?

Gerald


diff --git a/htdocs/gcc-13/porting_to.html b/htdocs/gcc-13/porting_to.html
index 170da096..8a2822ff 100644
--- a/htdocs/gcc-13/porting_to.html
+++ b/htdocs/gcc-13/porting_to.html
@@ -122,12 +122,14 @@ the operand as an lvalue.<br>
 
 <h3 id="excess-precision">Excess precision changes</h3>
 
-<p>GCC 13 implements in C++ <a href="changes.html#cxx">excess precision support</a>
-which has been before implemented just in the C front end.  The new behavior is
-enabled by default in <code>-std=c++</code><em>NN</em> modes and e.g. when
-<code>FLT_EVAL_METHOD</code> is 1 or 2 affects behavior of floating point
-constants and expressions.  E.g. for <code>FLT_EVAL_METHOD</code> equal
-to 2 on ia32:
+<p>GCC 13 implements <a href="changes.html#cxx">excess precision
+support</a>, which was implemented just in the C front end
+before, in C++. The new behavior is enabled by default in
+<code>-std=c++</code><em>NN</em> modes and when
+<code>FLT_EVAL_METHOD</code> is 1 or 2 and affects the behavior of
+floating point constants and expressions.</p>
+
+<p>E.g. for <code>FLT_EVAL_METHOD</code> equal to 2 on ia32
 
 <pre><code>
 #include &lt;stdlib.h&gt;
@@ -139,11 +141,11 @@ will not abort with standard excess precision, because constants and expressions
 in <code>float</code> or <code>double</code> are evaluated in precision of
 <code>long double</code> and demoted only on casts or assignments, but will
 abort with fast excess precision, where whether something is evaluated in
-precision of <code>long double</code> or not depends on what evaluations are
-done in the i387 floating point stack or are spilled from it.
+<code>long double</code> precision depends on what evaluations are
+done in the i387 floating point stack or are spilled from it.</p>
 
-The <code>-fexcess-precision=fast</code> option can be used to request the
-previous behavior.
+</p>The <code>-fexcess-precision=fast</code> option can be used to
+request the previous behavior.</p>
 
 <h3 id="alloc-rebind">allocator_traits&lt;A&gt;::rebind_alloc&lt;A::value_type&gt; must be A</h3>
 

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: [wwwdocs] gcc-13/porting_to.html: Document C++ -fexcess-precision=standard
  2023-03-09  7:09     ` Gerald Pfeifer
@ 2023-03-09  8:05       ` Jakub Jelinek
  0 siblings, 0 replies; 8+ messages in thread
From: Jakub Jelinek @ 2023-03-09  8:05 UTC (permalink / raw)
  To: Gerald Pfeifer; +Cc: Martin Liška, gcc-patches

On Thu, Mar 09, 2023 at 08:09:02AM +0100, Gerald Pfeifer wrote:
> I struggled a bit understanding this and so have come up with what I 
> hope is simpler (without changing the meaning).
> 
> What do you think of the change below?

LGTM, thanks.
> 
> diff --git a/htdocs/gcc-13/porting_to.html b/htdocs/gcc-13/porting_to.html
> index 170da096..8a2822ff 100644
> --- a/htdocs/gcc-13/porting_to.html
> +++ b/htdocs/gcc-13/porting_to.html
> @@ -122,12 +122,14 @@ the operand as an lvalue.<br>
>  
>  <h3 id="excess-precision">Excess precision changes</h3>
>  
> -<p>GCC 13 implements in C++ <a href="changes.html#cxx">excess precision support</a>
> -which has been before implemented just in the C front end.  The new behavior is
> -enabled by default in <code>-std=c++</code><em>NN</em> modes and e.g. when
> -<code>FLT_EVAL_METHOD</code> is 1 or 2 affects behavior of floating point
> -constants and expressions.  E.g. for <code>FLT_EVAL_METHOD</code> equal
> -to 2 on ia32:
> +<p>GCC 13 implements <a href="changes.html#cxx">excess precision
> +support</a>, which was implemented just in the C front end
> +before, in C++. The new behavior is enabled by default in
> +<code>-std=c++</code><em>NN</em> modes and when
> +<code>FLT_EVAL_METHOD</code> is 1 or 2 and affects the behavior of
> +floating point constants and expressions.</p>
> +
> +<p>E.g. for <code>FLT_EVAL_METHOD</code> equal to 2 on ia32
>  
>  <pre><code>
>  #include &lt;stdlib.h&gt;
> @@ -139,11 +141,11 @@ will not abort with standard excess precision, because constants and expressions
>  in <code>float</code> or <code>double</code> are evaluated in precision of
>  <code>long double</code> and demoted only on casts or assignments, but will
>  abort with fast excess precision, where whether something is evaluated in
> -precision of <code>long double</code> or not depends on what evaluations are
> -done in the i387 floating point stack or are spilled from it.
> +<code>long double</code> precision depends on what evaluations are
> +done in the i387 floating point stack or are spilled from it.</p>
>  
> -The <code>-fexcess-precision=fast</code> option can be used to request the
> -previous behavior.
> +</p>The <code>-fexcess-precision=fast</code> option can be used to
> +request the previous behavior.</p>
>  
>  <h3 id="alloc-rebind">allocator_traits&lt;A&gt;::rebind_alloc&lt;A::value_type&gt; must be A</h3>
>  

	Jakub


^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2023-03-09  8:05 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09 16:20 [wwwdocs] gcc-13/changes.html: Document C++ -fexcess-precision=standard Jakub Jelinek
2023-02-10  9:06 ` Gerald Pfeifer
2023-03-02 10:32   ` [wwwdocs] gcc-13/porting_to.html: " Jakub Jelinek
2023-03-02 12:40     ` Martin Liška
2023-03-02 23:05     ` Gerald Pfeifer
2023-03-02 23:16       ` Jakub Jelinek
2023-03-09  7:09     ` Gerald Pfeifer
2023-03-09  8:05       ` Jakub Jelinek

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).