const and static (was: C vs. assembly...)

fjh@cs.mu.OZ.AU
27 Mar 1996 00:11:24 -0500

          From comp.compilers

Related articles
Re: C code .vs. Assembly code for Microcontrollers/DSPs ? cdg@nullstone.com (1996-03-16)
const and static (was: C vs. assembly...) mark@omnifest.uwm.edu (1996-03-25)
const and static (was: C vs. assembly...) fjh@cs.mu.OZ.AU (1996-03-27)
Re: const and static (was: C vs. assembly...) cdg@nullstone.com (1996-03-27)
Re: const and static (was: C vs. assembly...) mason@ease.com (1996-03-29)
Re: const and static (was: C vs. assembly...) cdg@nullstone.com (1996-04-02)
Re: const and static (was: C vs. assembly...) jmccarty@sun1307.spd.dsccc.com (1996-04-02)
Re: const and static (was: C vs. assembly...) KingD@rnd1.indy.tce.com (King Dale) (1996-04-11)
Re: const and static (was: C vs. assembly...) cdg@nullstone.com (1996-04-12)
[4 later articles]
| List of all articles for this month |
From: fjh@cs.mu.OZ.AU
Newsgroups: comp.compilers
Date: 27 Mar 1996 00:11:24 -0500
Organization: Compilers Central
References: 96-03-106 96-03-181
Keywords: C, optimize, performance



>From cdg@nullstone.com (Christopher Glaeser):
> int f_()
> {
> static integer i;
>
> for (i = 1; i <= 100; ++i) { }
> return 0;
> }


mark@omnifest.uwm.edu (Mark Hopkins) writes:
>A decent compiler should optimize this to
>
>int f_() { return 0; }
[...]


Absolutely right. The trouble is that decent compilers are so hard to find!


I just tried the C compilers that come with Solaris 2.5, Alpha/OSF
3.2, and Irix 5.2, plus gcc and lcc, and none of them perform this
optimization. [*] This is the point that Christopher Glaeser was
making.


[*] Actually, that's not entirely true: the Irix 5.2 C compiler will
perform it if you compile with -O3 or higher. However, those
optimization levels require -non_shared, which means you can't use
shared libraries.


--
Fergus Henderson WWW: http://www.cs.mu.oz.au/~fjh
fjh@cs.mu.oz.au PGP: finger fjh@128.250.37.3
--


Post a followup to this message

Return to the comp.compilers page.
Search the comp.compilers archives again.