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 -fno-signed-zeros is used, > then MIN/MAX would be the same as a > b ? a : b which would not cause > a trap. > > If we think they should not trap, then I will create a patch and test > it for GCC 14.
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 fmax/fmin (even with NaN), but meanwhile there's a plethora of min/max function variants ... I'm sure Joseph can clarify whether unconditionally returning honor_snans (or false?) for MIN/MAX_EXPR from operation_could_trap_helper_p would be correct. Richard. > Thanks, > Andrew Pinski > -- Richard Biener <rguent...@suse.de> SUSE Software Solutions Germany GmbH, Frankenstrasse 146, 90461 Nuernberg, Germany; GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman; HRB 36809 (AG Nuernberg)