Re: MIN/MAX and trapping math and NANs

2023-04-11 Thread Joseph Myers
On Tue, 11 Apr 2023, Michael Matz via Gcc wrote: > Note that this makes minNum/maxNum (and friends) not associative. Also, > different languages and different hardware implement fmin/fmax different > and sometimes in conflict with 754-2008 (e.g. on SSE2 maxsd isn't > commutative but maxNum

Re: MIN/MAX and trapping math and NANs

2023-04-11 Thread Michael Matz via Gcc
Hello, On Tue, 11 Apr 2023, Richard Biener via Gcc wrote: > In the case we ever implement conforming FP exception support > either targets would need to be fixed to mask unexpected exceptions > or we have to refrain from moving instructions where the target > implementation may rise exceptions

Re: MIN/MAX and trapping math and NANs

2023-04-11 Thread Richard Biener via Gcc
On Tue, 11 Apr 2023, LIU Hao wrote: > ? 2023/4/11 16:00, Richard Biener via Gcc ??: > > I think without NaNs MIN/MAX cannot raise any exceptions (I'm not > > even sure whether MIN/MAX involving NaN will set invalid, but > > most certainly with sNaN it will trap and return a quiet NaN?). > > The C

Re: MIN/MAX and trapping math and NANs

2023-04-11 Thread LIU Hao via Gcc
在 2023/4/11 16:51, LIU Hao via Gcc 写道: My interpretation is that if one argument is a SNaN and the other is not, `fmax()` shall return the SNaN unchanged, without converting it to a QNaN. (F.10.9.2 The fmax functions, ISO/IEC 9899:2017) 'the other is not' means the other operand is a

Re: MIN/MAX and trapping math and NANs

2023-04-11 Thread LIU Hao via Gcc
在 2023/4/11 16:00, Richard Biener via Gcc 写道: I think without NaNs MIN/MAX cannot raise any exceptions (I'm not even sure whether MIN/MAX involving NaN will set invalid, but most certainly with sNaN it will trap and return a quiet NaN?). The C standard doesn't document any exceptions for

Re: MIN/MAX and trapping math and NANs

2023-04-11 Thread Richard Biener via Gcc
On Sat, 1 Apr 2023, Andrew Pinski wrote: > Hi, > I noticed while working on phi-opt, that MIN/MAX EXPR (and the > corresponding RTL codes) both can return true for trapping even if > NANs are not honored (that is -ffinite-math-only). Is this true? I > would have assumed when -ffinite-math-only

MIN/MAX and trapping math and NANs

2023-04-01 Thread Andrew Pinski via Gcc
Hi, I noticed while working on phi-opt, that MIN/MAX EXPR (and the corresponding RTL codes) both can return true for trapping even if NANs are not honored (that is -ffinite-math-only). Is this true? I would have assumed when -ffinite-math-only -fno-signed-zeros is used, then MIN/MAX would be the