From: | James Kanze US/ESC 60/3/141 #40763 <kanze@lts.sel.alcatel.de> |
Newsgroups: | comp.compilers |
Date: | 25 Mar 1996 21:51:22 -0500 |
Organization: | Compilers Central |
References: | 96-03-006 96-03-091 96-03-106 96-03-136 |
Keywords: | optimize |
>> [Do people really not use const and static? -John]
cdg@nullstone.com (Christopher Glaeser) writes:
>
>2) static - Static can cause significant performance problems for many
>C compilers. In particular, few C compilers can keep static variables
>in registers over a region of code.
fjh@cs.mu.OZ.AU writes:
|> I think the original poster who suggested using `static' for optimization
|> purposes was suggesting it as an alternative to making variables
|> and functions global, not as an alternative to using auto variables.
|> When used for this purpose, I suspect it may have some effect. For
|> example, compilers may be more inclined to inline a static function.
On 80x86 architecture, making the functions static can be a
significant win, even without inlining. At least one compiler I have
used would always generate a near call for a static function, for
example. (More importantly, this also meant that static functions
always had a near return.)
Sort of the opposite effect, but I also know of a compiler which
systematically loaded the segment register for all accesses to global
variables, even those declared in the module being compiled (even
though it also took pains to set up DS for the data in the module
being compiled).
In practice, the choice between near and far could make an enormous
difference in protected mode, where loading a segment register
involved loading the entire segment descripter (5 words, if memory
serves me right).
--
James Kanze Tel.: (+33) 88 14 49 00 email: kanze@gabi-soft.fr
GABI Software, Sarl., 8 rue des Francs-Bourgeois, F-67000 Strasbourg, France
--
Return to the
comp.compilers page.
Search the
comp.compilers archives again.