Hi, Is there a recommended way to round to the nearest whole (x86 RC field of FPU control = 00) ? It appears an intentional truncation instruction is generated (if ms disassembly is correct): IRBuilder<>::CreateFPToSI %1 = fptosi double %0 to i64 00370025 fisttp qword ptr [esp] Thanks, Bob -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100928/42385881/attachment.html>
On Sep 28, 2010, at 4:14 PM, Bob wrote:> Hi, > > Is there a recommended way to round to the nearest whole (x86 RC field of FPU control = 00) ? > > It appears an intentional truncation instruction is generated (if ms disassembly is correct): > > IRBuilder<>::CreateFPToSI > > %1 = fptosi double %0 to i64 > > 00370025 fisttp qword ptr [esp] >Hi Bob, We don't have great support for this. We support the rounding modes that C uses, but don't have the ability to control the rounding flags in the machine, and don't have a way to tell the optimizer that the program is fiddling with them. -Chris -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100928/86b554a6/attachment.html>
On Sep 28, 2010, at 4:14 PMPDT, Bob wrote:> Hi, > > Is there a recommended way to round to the nearest whole (x86 RC field of FPU control = 00) ? > > It appears an intentional truncation instruction is generated (if ms disassembly is correct):The description of fptosi as "converts...into the nearest (rounding towards zero)" is perhaps a little confusing. That is actually a truncation. No, there's no way to change rounding modes, although people keep talking about adding it. It is not an easy thing to do. -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.llvm.org/pipermail/llvm-dev/attachments/20100928/714f6111/attachment.html>