This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
[Bug middle-end/24729] New: function calls created by builtins do not make use of inline definitions
- From: "ghazi at gcc dot gnu dot org" <gcc-bugzilla at gcc dot gnu dot org>
- To: gcc-bugs at gcc dot gnu dot org
- Date: 8 Nov 2005 03:43:14 -0000
- Subject: [Bug middle-end/24729] New: function calls created by builtins do not make use of inline definitions
- Reply-to: gcc-bugzilla at gcc dot gnu dot org
When doing transformations on builtins, if the builtin results in a function
call that has an inline expansion, GCC emits a library call not the inline
function body. E.g. glibc defines an inline for fputc_unlocked. Given this
code:
#define _GNU_SOURCE
#include <stdio.h>
#define MAX 100000000
int main ()
{
int i;
for (i=0; i<MAX; i++)
{
#ifdef FPUTC_DIRECT
fputc_unlocked('1', stdout);
#else
fputs_unlocked("1", stdout);
#endif
}
return 0;
}
If you compile it on a glibc box (I used x86_64-unknown-linux-gnu) with -O2 and
look at the assembly the fputs_unlocked gets turned into fputc_unlocked as
expected due to a strlen of 1 in the parameter, but nothing is further
optimized. However if you use -DFPUTC_DIRECT, you should see that GCC inserts
the inline definition of fputc_unlocked and this version of the code runs about
10x faster than the library call to fputc_unlocked.
When expanding function calls created by builtin substitution, GCC should check
if that identifier refers to an inline function and substitute that definition
if possible.
--
Summary: function calls created by builtins do not make use of
inline definitions
Product: gcc
Version: 4.1.0
Status: UNCONFIRMED
Severity: normal
Priority: P3
Component: middle-end
AssignedTo: unassigned at gcc dot gnu dot org
ReportedBy: ghazi at gcc dot gnu dot org
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=24729