Does the MCU function and performance exactly same for (-O3) and (-Os)?

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

Does the MCU function and performance exactly same for (-O3) and (-Os)?

ソリューションへジャンプ
542件の閲覧回数
hilverlee
Contributor II

For S32DS C Compiler/ Standard S32DS C++ Compiler - Optimization, when we change the setting from Optimize most (-O3) to Optimize size (-Os), with the same source code, does the MCU function and performance keeps exactly same? If not, what will be the difference?

タグ(2)
0 件の賞賛
1 解決策
505件の閲覧回数
hilverlee
Contributor II

I think it is an excellent reply and perfectly answered my questions, thank you very much.

元の投稿で解決策を見る

0 件の賞賛
2 返答(返信)
523件の閲覧回数
Daniel-Aguirre
NXP TechSupport
NXP TechSupport

Hi,

The difference in optimizations are related directly to the compiler being used. We can find the following regarding your inquiry (link: Optimize Options (Using the GNU Compiler Collection (GCC))

-O3

Optimize yet more. -O3 turns on all optimizations specified by -O2 and also turns on the following optimization flags:

-Os

Optimize for size. -Os enables all -O2 optimizations except those that often increase code size:

Related to function, if you create a blink application, both optimizations should result in your application blinking a LED. The problem with function comes when your application becomes complex and the optimizations start harming the overall functionality of your application. This is related to the optimizations that are being done, meaning the code was written to work as one thing, but the optimization changes the overall logic (due to the changes creating a better performance, changing memory accesses and implementing optimized loops) and this new logic can happen to be not compliant with what the original idea was, hence harming functionality.

As for performance, each level will create a different kind of optimization related to loop-unrolling, memory access pipelining and so. Given that -Os is related to size and -O3 is related more optimizations, we can assume that -O3 should have a better performance than the -Os one.

Still, the optimization level is to be taken with care, given that a -Os optimized application can be running as expected, but once you up the optimization to -O3, the application can fail, due to non-compliant behavior.

Again, this is more related to the compiler itself, rather than the NXP products. We might recommend talking a look into the different optimization flags and see if any of them can be non-compliant with your application.

Please, let us know.

 

 

506件の閲覧回数
hilverlee
Contributor II

I think it is an excellent reply and perfectly answered my questions, thank you very much.

0 件の賞賛