This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug c/48139] New: __builtin_lrintf() becomes a library call, not an cvtss2si instruction
- From: "sgunderson at bigfoot dot com" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: Tue, 15 Mar 2011 20:10:26 +0000
- Subject: [Bug c/48139] New: __builtin_lrintf() becomes a library call, not an cvtss2si instruction
- Auto-submitted: auto-generated
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=48139
Summary: __builtin_lrintf() becomes a library call, not an
cvtss2si instruction
Product: gcc
Version: unknown
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: c
AssignedTo: unassigned@gcc.gnu.org
ReportedBy: sgunderson@bigfoot.com
Hi,
It seems there is no way on x86-64 (short of an asm() statement) to get direct
access to the cvtss2si instruction, ie. convert a single float to an int in the
current rounding mode. Even __builtin_lrintf() becomes a library call to
glibc's lrintf(), which in itself only contains a single instruction and then a
ret. (If I set -fno-math-errno, I do get the instruction, but this is
unfortunately not an option for me.)
I've been told that this may or may not be correct behavior; it's a bit unclear
if lrintf() should set errno or not according to C99 and glibc's
math_errhandling setting. I guess this either is a missed optimization in GCC
_or_ a bug in glibc, though. It seems to me the former is more likely, though,
given that the entire point of lrint() and friends seems to be being able to do
quick float-to-int without having to deal with special code for NaN and the
likes.