lkml.org 
[lkml]   [1999]   [Jun]   [4]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Linux/i386 fastcall support
Konstantin Boldyshev wrote:
>
> I've got a suggestion for linux kernel on i386: what about
> fastcall support (i.e. passing function parameters through
> registers, not the stack and correct compiling with -mrtd
> and -mregparm gcc switches)? Fastcall will surely improve
> overall perfomance of kernel.

careful - i've spent quite some time optimizing ia32 code
(as generated by gcc/egcs) to use the best calling conventions
everywhere (this was for a raytracer, and on pii).
If there's one thing you can be sure of, it's that fastcall
won't automatically give you a performance improvement.

It depends very much on the function (what it does, how it's
usually called etc), and varies significantly.

Basically, on modern ia32 cpus (and decent compilers) you can get
the push/pops almost for free, while moving register contents
around often introduces stalls (dependecies etc).

As a general rule: regparm(1) (ie 1st arg in %eax, rest on stack)
is usually (not always) a win, anything else needs careful
examination and benchmarking. Also functions that only take 1-3
pointers as args and operate only on objects directly dereferenced
from these pointers usually benefit from regparm().

Even when, after changing the calling convetion for some function,
you look at all the places it's called from (and the f() itself)
and it appears the change was "obviously" an improvment - benchmarking
can show it actually slows the code down...

And of course it all depends on the cpu family, vendor etc. Intel
seems to have done a good job optimizing for the common convention
- cdecl.


> drawback is some assembler code.. however it can be
> easily enclosed in C functions to let compiler use specified

actually the asm functions look like obvious candidates for
regparm(). _after_ it is proven that it's actually a win, on a
case by case basis.


> ps: I successfully compiled current kernel with -mrtd and -mregparm=x but it
> doesnot work :)

stdcall does noticeably worse on 686 anyway.


-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/

\
 
 \ /
  Last update: 2005-03-22 13:52    [W:0.041 / U:1.476 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site