On May 8, 2020 4:28:24 PM GMT+02:00, Alexander Monakov <amona...@ispras.ru> wrote: >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.
The IFNs are supposed to match fmin and fmax from the C standard which IIRC have IEEE semantics. Note the ISA likely behaves this way because it matches open coded C semantics. Arm folks added the IFNs so I have to dig up what exactly they were after... I'd hate to add a third variant here... Richard. >Alexander