This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
HORRIBLE inliner defaillance
- From: Paolo Carlini <pcarlini at suse dot de>
- To: gcc at gcc dot gnu dot org
- Cc: jh at suse dot de, roger at eyesopen dot com, Jerry Quinn <jlquinn at optonline dot net>, Benjamin Kosnik <bkoz at redhat dot com>
- Date: Fri, 24 Oct 2003 18:19:23 +0200
- Subject: HORRIBLE inliner defaillance
Hi everyone,
following up to Jerry heads up of a while ago
(http://gcc.gnu.org/ml/libstdc++/2003-02/msg00056.html) I really
would like to have some feedback from the compiler people about
this horrible thing.
Consider the /trivial/ but absolutely widespread pattern:
inline void
copy_trivial(const char* __first, const char* __last,
char* __result)
{
__builtin_memcpy(__result, __first, __last - __first);
}
int main()
{
char x[] = "1234567890123456789012345678901";
char y[32];
long i;
for (i = 0; i < 100000000; i++)
//copy_trivial(x, x+sizeof(x), y);
__builtin_memcpy(y, x, sizeof(x));
}
Believe it or not, there is no way to have copy_trivial fully inlined
and we pay a 100x price :((( for using copy_trivial instead of directly
calling memcpy.
This means, f.i., that, in the whole library there is no point in trying
to use memcpy instead of memmove.
Perhaps I'm missing something important, I would be /happy/ to be
wrong and in fact there is a simple way to have copy_trivial inlined.
Thanks in advance,
Paolo.