--- Andrew Pinski wrote: > On May 24, 2006, at 2:54 AM, Etienne Lorrain wrote: > > Another calling convention could be to not only return the "return > > value" in %eax (or %edx:%eax for long long returns) but also its > > comparisson to zero in the flags, so that you get: > > call foo > > jg .Lwarning > > jnz .Lerror > > And you think this will help? It will at most 1-10 cycles depending > on the processor.
The same can be said of register passing argument, at least for ia32 passing a parameter in %edx/%eax instead of the stack saves one or two loads so few cycles - and by increasing the register pressure you often get a slower and (a lot) bigger function (what I have seen). But in some cases, a function attribute placed in the right position (usually very small functions) can help. > And if you have a call in the hot loop, you are screwed > anyways because you will have to deal with the overhead of the call. I am not sure of what you are refering to, but there is plenty of places where you are screwed - for instance the stack readjustment is the better done by "mov %ebp,%esp" instead of "add $16,%esp". > So it will end up being about even. I was thinking of very small functions, kind of one instruction, something like: asm (" atomic_dec: \n lock dec (%eax) \n ret "); extern unsigned atomic_dec (unsigned *counter) __attribute__((return_flags)); void fct (void) { while (atomic_dec()) wait(); } But it was an intermediate solution to the problem of passing two return values to a function - I am not sure it worth the time to implement. Etienne. ___________________________________________________________________________ Yahoo! Mail réinvente le mail ! Découvrez le nouveau Yahoo! Mail et son interface révolutionnaire. http://fr.mail.yahoo.com