Using MSVC _ftol2 runtime function for fptoui on Win32

Hi Joe & Michael,

In rev. 151382 you have changed the fptoui implementation of the x86 codegen for win32.

Before the change fptoui was lowered to

flds 16(%esp)

fisttpll 8(%esp)

movl 8(%esp), %eax

After the change fptoui is lowered to

flds 40(%esp)

calll _ftol2

Please note that the assumption that _ftol2 doesn’t modify ECX isn’t true on sandybridge platform.

Could you share with me the reasons behind this change? Did you get better performance after this change?



"fisttp" is only available with SSE3 or later, and before that change, if
SSE3 was unavailable, legalization would lower fptoui and fptosi to a
libgcc/compiler-rt call that does not exist on Win32, so the change was
necessary for compatibility with MSVC. If SSE3 is enabled, it should use
'fisttp', and if _ftol2 clobbers ECX, the pseudo-instruction for it can be
fixed to reflect that. Those would both be good things to fix.