On Fri, 2007-11-02 at 23:54 -0400, Robert Dewar wrote: > skaller wrote: > > On Fri, 2007-11-02 at 18:45 -0700, Andrew Pinski wrote: > >>> This is not true. If you use a register for any purpose like this, > >>> it can't be used for anything else and that has a cost. > >> This is a segment register. Please go and read about what segment > >> registers. > > > > I know how the x86 works quite well .. perhaps unfortunately I've > > written several major applications in x86 assembler (including > > a complete text editor). > > in which case you should understand that the use of FS is free > >
No. Free for whom? Sure, if the ABI doesn't specify it and gcc doesn't otherwise use it then gcc using it doesn't impact an ISO C program. but it *could* impact a program that had already chosen to conditionally use that register if it happened to be possible with the C compiler, as it is with gcc, or if the compiler didn't use it (promise!) and one was prepared to add some assembler. I'm sure you know this kind of thing is quite common in language translators and interpreters, especially with respect to memory allocation (possibly garbage collection) .. in fact the same kind of use as suggested for __thread. Neko, for example, uses a register. AFAIK MLton does the same kind of thing. If gcc team thinks ANY register is free to steal they'd be wrong -- that doesn't mean it shouldn't be used, just that it definitely is NOT free. I can tell you I definitely considered using FS for the Felix thread frame pointer to save passing that pointer between every function.. -- John Skaller <skaller at users dot sf dot net> Felix, successor to C++: http://felix.sf.net