Re: [ILUG] gcc optimizations

From: Mel (mel at domain csn.ul.ie)
Date: Fri 20 Aug 1999 - 13:12:10 IST


On Fri, 20 Aug 1999, Caolan McNamara wrote:

> I was wondering about strlen and string literals with gcc earlier on.
> so i decided to do a little test.

<snip>

> But what i wondered was, if there was a list of what gcc does to optimize
> anywhere, or it is just a hodgepodge of magic rules that you have to trawl
> through experimentation or the gcc source to determine.

Best ref I could see was on

http://www.delorie.com/gnu/docs/gcc/gcc.1.html

it lists all the optimizations that can be done but not in any great
detail. I'm not sure which optimization would have been used for yours but
it could have been "-finline-functions" which integrates simple functions
into the caller. strlen is a well known simple function and it could be a
case the compiler watches out for known functions with fixed arguements
like your program is like. There is a name for the compiler optimization
where expressions that can be calculated at compile time are done but I
can't remember what it's called. eg

a = 1
b = 2
c = a + b

a decent compiler would change this to

a = 1
b = 2
c = 3

rather than doing the calculation at run-time. I might remember what this
is called before the day is out :-(

        Mel



This archive was generated by hypermail 2.1.6 : Thu 06 Feb 2003 - 13:04:29 GMT