On Fri, 8 May 2020, Uros Bizjak wrote:

> > Am I missing something?
> 
> Is the above enough to declare min/max as IEEE compliant?

No. SSE min/max instructions semantics match C expression x < y ? x : y.
IEEE min/max operations are commutative when exactly one operand is a NaN,
and so are C fmin/fmax functions:

    fmin(x, NaN) == fmin(NaN, x) == x   // x is not a NaN

In contrast, (x < y ? x : y) always returns y when x or y is a NaN, and
likewise the corresponding SSE instructions are not commutative.

Therefore they are explicitly non-compliant in presence of NaNs.

I don't know how GCC defines the semantics of GIMPLE min/max IFNs.

Alexander

Reply via email to