[LLVMdev] Using MSVC _ftol2 runtime function for fptoui on Win32

Joe Groff arcata at gmail.com
Wed Feb 13 13:48:04 PST 2013


On Wed, Feb 13, 2013 at 8:04 AM, Badouh, Asaf <asaf.badouh at intel.com> wrote:

>  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.

-Joe
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20130213/2a8da333/attachment.html>


More information about the llvm-dev mailing list