This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: optimisation question
- From: Chris Jefferson <caj at cs dot york dot ac dot uk>
- To: "Remy X.O. Martin" <vsxo at hotmail dot com>
- Cc: gcc at gcc dot gnu dot org
- Date: Mon, 31 Jan 2005 14:34:09 +0000
- Subject: Re: optimisation question
- References: <20050131152659.0dc92d6c@portia.local>
Remy X.O. Martin wrote:
Hello,
I spent some time with Apple's Shark yesterday, profiling some of my code (rather, running a particular batch). Shark is a tool which samples running applications, and then allows one to find the most expensive expressions, giving hardware-specific suggestions on how to improve performance. I got 3 suggestions:
1) use a specific compiler option (-mdynamic-no-pic)
2) statements like a= c= d; are not (necessarily) optimal
3) Rewrite
for( i= 0; i< dest->N; i++ ) dest->array[i]= SOME_EXPRESSION;
as (e.g.)
for( i= 0, N=dest->N, array=dest->array; i< N; i++ ) array[i]= SOME_EXPRESSION;
I'm not sure about 1 and 2. The main problem with 3 is that it may hard
to tell array[i] = SOME_EXPRESSION cannot effect dest->N or dest->array.
Unless SOME_EXPRESSION contains a function this would however suprise
me. The alising code has got better in the current CVS. If you have a
specific example then that would be interesting to see.
Chris