Code Optimization (for speed)?

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

Code Optimization (for speed)?

1,379件の閲覧回数
GregM
Contributor I
Hi,

I'm using CW7.3 on the DSP56F805EVM board and I need my code to run as quickly as possible.

1) Will the code run faster if all variables are declared as signed rather than unsigned - or does the built is optimization correct these for the quickest possible operation?

2) Which will result in fewer instructions, a for( ; ; ) or a while(1)? In an un-optimized environment, the while(1) would result in a fetch from ROM, a compare & goto - whereas a for( ; ; ) would result in just a goto. Does the compiler optimize the while(1) correctly to just a goto?
(yes - I am stretching for clock cycles)

3) Can anyone provide me with more tips/tricks/techniques to code for speedy execution?

Code size is not a worry - it's the execution time I need to get down, whilst still coding in C.

Thanks for any assistance,

Greg
ラベル(1)
タグ(1)
0 件の賞賛
返信
1 返信

440件の閲覧回数
bobc
Contributor II
My main tip would be to turn on optimisation and look at the output of the compiler to see what code it generates. There is a lot of "folklore" around optimisation which either was true once but isn't now or never was true anyway. There are a lot of special cases which depend on the specific target and compiler implementation. It's best not to rely on second hand info or make assumptions about what the compiler will do.

I have never heard signed variables are faster, what makes you think that?

To look at the assembler output use the Debugger "mixed" view, or turn on the option to generate assembler.

Cheers


Message Edited by bobc on 2009-02-17 12:20 PM
0 件の賞賛
返信