* 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 qNaNs. > > Sorry, do you mean contracting 'x + x - x' to 'x'?
Yes. > That is not allowed due to different result and lack of FP exception > for infinities. FP exceptions do not need to preserved in C11 (it's a recommended practice in Annex F only, and the main text explicitly allows changes). But you are right that inf - inf would result in a NaN, so that's a different result that cannot be explained by infinite intermediate precision. Huh, so it's a bad example. Sorry! 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? > Contracting 'x + x - x' to fma(x, 2, -x) would be fine. It still changes the result, doesn't it? Thanks, Florian