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: unassig...@gcc.gnu.org ReportedBy: sgunder...@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.