This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]