Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Joseph Myers
On Mon, 18 Sep 2023, Alexander Monakov wrote: > > On Mon, 18 Sep 2023, Florian Weimer wrote: > > > Okay, you meant “changing the result” as in “changing the result in a > > permitted way”. Sorry, was confused. So this is a bad example all > > around. Are there better ones (that don't involve

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Alexander Monakov
On Mon, 18 Sep 2023, Florian Weimer wrote: > Okay, you meant “changing the result” as in “changing the result in a > permitted way”. Sorry, was confused. So this is a bad example all > around. Are there better ones (that don't involve FMA)? If you're looking for something similar to your ori

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Florian Weimer via Gcc
* Alexander Monakov: >> > Contracting 'x + x - x' to fma(x, 2, -x) would be fine. >> >> It still changes the result, doesn't it? > > I don't follow. I doesn't change the result for infinities (produces > a NaN). It changes the result when x is so large that 'x + x' is > not representable (exponen

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Alexander Monakov
On Mon, 18 Sep 2023, Martin Uecker wrote: > > The hardest part would be popping the pragma state when leaving a block, > > which didn't seem difficult (at least for C). > > It is fairly restricted where it can appear, it essentially operates > on the level of compound statements (!= blocks).

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Martin Uecker
Am Montag, dem 18.09.2023 um 14:43 +0300 schrieb Alexander Monakov: > On Mon, 18 Sep 2023, Jakub Jelinek wrote: > > > Perhaps we should add some initial hammer approach for the pragma, like > > if you ever use the pragma to turn it somewhere off, it is turned off > > globally, or ditto per functio

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Alexander Monakov
On Mon, 18 Sep 2023, Florian Weimer via Gcc wrote: > But the contraction would still be valid after an isfinite check > (something that ranger might catch these days), or with with > -ffinite-math-only in general. Right? Nope, still not valid for negative zero ('x + x - x' would yield positive

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Alexander Monakov
On Mon, 18 Sep 2023, Jakub Jelinek wrote: > Perhaps we should add some initial hammer approach for the pragma, like > if you ever use the pragma to turn it somewhere off, it is turned off > globally, or ditto per function. Might be far easier than trying to > make it precise that contraction is

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Florian Weimer via Gcc
* Richard Biener: >> How much numerical code is compatible with that? For example, David >> Goldberg's What Every Computer Scientist Should Know About >> Floating-Point Arithmetic (revised) contains this sentence: >> >> | A language definition that does not require parentheses to be honored >> |

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Florian Weimer via Gcc
* Alexander Monakov: > On Mon, 18 Sep 2023, Florian Weimer via Gcc wrote: > >> x - x is different because replacing it with 0 doesn't seem to be a >> valid contraction because it's incorrect for NaNs. x + x - x seems to >> be different in this regard, but in our implementation, there might be a >

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Jakub Jelinek via Gcc
On Mon, Sep 18, 2023 at 01:26:54PM +0200, Martin Uecker wrote: > > I think that changing the default to =standard without -ffast-math is > > reasonable. > > IIRC the standard allows such default if it's indicated, so it doesn't > > require > > =off anywhere. > > The C standard requires a pragma t

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Martin Uecker
Am Montag, dem 18.09.2023 um 10:06 +0200 schrieb Richard Biener via Gcc: > On Mon, Sep 18, 2023 at 9:51 AM Alexander Monakov wrote: > > > > Hi Florian, > > > > On Thu, 14 Sep 2023, Alexander Monakov wrote: > > > > > > > > On Thu, 14 Sep 2023, Florian Weimer via Gcc wrote: > > > > > > > While

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Alexander Monakov
On Mon, 18 Sep 2023, Florian Weimer via Gcc wrote: > x - x is different because replacing it with 0 doesn't seem to be a > valid contraction because it's incorrect for NaNs. x + x - x seems to > be different in this regard, but in our implementation, there might be a > quirk about sNaNs and qNa

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Richard Biener via Gcc
On Mon, Sep 18, 2023 at 12:10 PM Florian Weimer wrote: > > * Richard Biener: > > >> > > GCC contraction behavior is rather inconsistent. It does not contract > >> > > x > >> > > + x - x without -ffast-math, for example, although I believe it would > >> > > be > >> > > permissible under the rule

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Florian Weimer via Gcc
* Richard Biener: >> > > GCC contraction behavior is rather inconsistent. It does not contract x >> > > + x - x without -ffast-math, for example, although I believe it would be >> > > permissible under the rules that enable FMA contraction. This whole > > Is that really just x + x - x? We curre

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Richard Biener via Gcc
On Mon, Sep 18, 2023 at 9:51 AM Alexander Monakov wrote: > > Hi Florian, > > On Thu, 14 Sep 2023, Alexander Monakov wrote: > > > > > On Thu, 14 Sep 2023, Florian Weimer via Gcc wrote: > > > > > While rebuilding CentOS Stream with -march=x86-64-v3, I rediscovered > > > several packages had test sui

Re: Concerns regarding the -ffp-contract=fast default

2023-09-18 Thread Alexander Monakov
Hi Florian, On Thu, 14 Sep 2023, Alexander Monakov wrote: > > On Thu, 14 Sep 2023, Florian Weimer via Gcc wrote: > > > While rebuilding CentOS Stream with -march=x86-64-v3, I rediscovered > > several packages had test suite failures because x86-64 suddenly gained > > FMA support. I say “redisc

Re: Concerns regarding the -ffp-contract=fast default

2023-09-14 Thread Alexander Monakov
On Thu, 14 Sep 2023, Florian Weimer via Gcc wrote: > While rebuilding CentOS Stream with -march=x86-64-v3, I rediscovered > several packages had test suite failures because x86-64 suddenly gained > FMA support. I say “rediscovered” because these issues were already > visible on other architectu

Concerns regarding the -ffp-contract=fast default

2023-09-14 Thread Florian Weimer via Gcc
While rebuilding CentOS Stream with -march=x86-64-v3, I rediscovered several packages had test suite failures because x86-64 suddenly gained FMA support. I say “rediscovered” because these issues were already visible on other architectures with FMA. So far, our package/architecture maintainers ha