https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125424
--- Comment #3 from Drea Pinski <pinskia at gcc dot gnu.org> ---
(In reply to Richard Biener from comment #2)
> (In reply to Drea Pinski from comment #1)
> > The documentation says the result will saturate to smallest/largest value.
> > And NaNs will be converted to 0.
>
> So they make formerly UB defined? How do they lower it, like
> wrap the FP with MIN/MAX operations?
Yes and yes:
x86_64:
.LCPI0_0:
.quad 0xc1e0000000000000
.LCPI0_1:
.quad 0x41dfffffffc00000
f(double):
xor eax, eax
ucomisd xmm0, xmm0
maxsd xmm0, qword ptr [rip + .LCPI0_0]
minsd xmm0, qword ptr [rip + .LCPI0_1]
cvttsd2si ecx, xmm0
cmovnp eax, ecx
ret
Though for aarch64, they just emit fcvtzs. I have not looked into other targets
of doing the conversion.