[LLVMdev] Best way to interface with MSVC _ftol2 runtime function for fptoui?

Joe Groff arcata at gmail.com
Tue Jan 24 14:30:25 PST 2012


On Fri, Jan 20, 2012 at 2:10 PM, Jakob Stoklund Olesen <stoklund at 2pi.dk> wrote:
> X86FloatingPoint.cpp with comments is all you get.

Thanks for your help, Jakob. Attached is a first-pass attempt at a
patch. I don't want to post to -commits yet because I have no idea if
this is fully correct, but it seems to work in simple test cases. Am I
on the right track? Could this patch ever break in cases where the
operand's vreg doesn't happen to get mapped to ST0? I'm still a bit
foggy on the internals of X86FloatingPoint.

One thing I noticed is that fptosi and fptoui both seem to always emit
a redundant SSE load/store when SSE is enabled, because of the check
at Target/X86/X86ISelLowering.cpp:7948. Can this check be easily
modified so it doesn't store if the operand is already in memory and
not actually in an SSE register? Should FP_TO_INTHelper switch over to
using CVTTS?2SI insns when SSE is available?

-Joe
-------------- next part --------------
A non-text attachment was scrubbed...
Name: llvm-ftol2.diff
Type: application/octet-stream
Size: 13256 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20120124/bbe252c0/attachment.obj>


More information about the llvm-dev mailing list