Code Optimization (for speed)?

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 

Code Optimization (for speed)?

1,250 次查看
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 回复

311 次查看
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 项奖励
回复