optimisation question

Chris Jefferson caj@cs.york.ac.uk
Mon Jan 31 15:11:00 GMT 2005


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



More information about the Gcc mailing list