How to choose optimization level in CodeWarrior DSC ( MC56F8XXXX ) ?

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to choose optimization level in CodeWarrior DSC ( MC56F8XXXX ) ?

Jump to solution
1,206 Views
547351265
Contributor II

How to choose optimization level 、speed vs. size、inter-procedural analysis & inline level in CodeWarrior  MC56F8xxx?

Is there any related documentation?

 

无标题.png

0 Kudos
1 Solution
1,200 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Zhang,

I suppose we do not have the dedicated doc for the optimization feature of CW tools, but the CW tools has "Help" function, you can refer to the optimization by searching the "optimization" as key words.

I get the result after searching the "optimization" as key words.

Hope it can help you

BR

XiangJun rong

xiangjun_rong_0-1606285849745.png

 

View solution in original post

0 Kudos
2 Replies
1,186 Views
Lorenzo_Mch_IT
Contributor IV

Hello 547351265,

Besides online help, give a look into (if you installed codewarrior mcu on C: drive)

"C:\Freescale\CW MCU v11.0\MCU\Help\PDF\MCU_DSC_Compiler.pdf"

(or just search for "MCU_DSC_Compiler.pdf" on your drive)

And especially at the following parts:

2.2.2.2 DSC Linker > General
2.2.3.4 DSC Compiler > Optimization
2.2.4.2 DSC Assembler > General

3.13 Object Code Organization and Generation Options

3.14 Optimization Options

If your MC56F8xxx DSC has a 56800EX core (i.e. "32bit core with extra instructions")  pay attention to its specific optimizations and how they must be enabled at linker, compiler and assembler level.

Another thing to pay attention is how peculiar is 56800/E/EX, for example when you call a function and then return, you "waste" at least 13 clock cycles (just by executing jsr/bsr and rts), that is the time it takes to perform 6..12 32bit multiplies.
So properly using inline functions and macros to minimize nested calls can give you a massive speedup.

Another thing is that DSC is optimized for 16bit operations, in lots of situations where it seems sensible to use 8bit data, it's actually better to keep things word aligned at 16bit etc. etc.

Also because of its peculiar architecture, constant data that in other microcontrollers is stored in flash memory, gets copied to ram, so if your code use lots of const char * strings (i.e. "this is a const char * string") enable string pooling so at least duplicated const strings don't eat precious ram space you may need for something else.

Another useful thing is that if your code fits in 128Kbyte (64KWords) using small memory model and small code model improves performance a lot.

And at last, some of the latest optimizations introduced seems to have some bugs (or maybe are dependent on other optimizations to be enabled/disabled), but to use those you have to use command-line options, so as long as you use GUI supported options you should be safe.

Basically, 56800xx DSCs are at their core 16bit DSPs based on fractional arithmetic (for example, that's why the 32..36bit accumulator registers are designed to discard very efficiently their lower 16bit fractional part) with more generic microcontroller instructions and features added at a later stage; as long as you use them as 16bit DSPs they are faster that lots of other "generic" microcontrollers, but if you use them like you would with and ARM or a MIPS cpu ... your mileage may vary (a lot).

Lorenzo Micheletto

0 Kudos
1,201 Views
xiangjun_rong
NXP TechSupport
NXP TechSupport

Hi, Zhang,

I suppose we do not have the dedicated doc for the optimization feature of CW tools, but the CW tools has "Help" function, you can refer to the optimization by searching the "optimization" as key words.

I get the result after searching the "optimization" as key words.

Hope it can help you

BR

XiangJun rong

xiangjun_rong_0-1606285849745.png

 

0 Kudos