1. 程式人生 > >KEIL編譯器C語言編譯選項優化等級說明

KEIL編譯器C語言編譯選項優化等級說明

0 Minimum optimization. Turns off most optimizations.It gives the best possible debug view and the lowest level of optimization. 近乎不優化,用於除錯程式碼。出現程式碼行不能設定斷點可如此設定試試。
1 Restrictedoptimization. Removes unused inline functions and unused static functions.Turns off optimizations that seriously degrade the debug view. Ifused with --debug, this option gives a satisfactorydebug view with good code density.部分優化。移除未呼叫的行內函數和靜態函式,關閉debug視窗優化,此狀態也能用於除錯
2 Highoptimization. If used with–debug, the debug viewmight be less satisfactory because the mapping of object code tosource code is not always clear.
This is the default optimization level.

        預設優化等級。如果處於debug狀態,部分程式碼行將不能被除錯,具體做了什麼優化好像沒說

3 Maximumoptimization.-O3 performs the same optimizationsas-O2 however the balance between space and timeoptimizations in the generated code is more heavily weighted towardsspace or time compared with-O2. That is:
-O3 -Otime aims to produce fastercode than-O2 -Otime, at the risk of increasingyour image size

-O3 -Ospace aims to produce smallercode than-O2 -Ospace, but performance might bedegraded.

In addition, -O3 performs extra optimizationsthat are more aggressive, such as:

High-levelscalar optimizations, including loop unrolling, for-O3-Otime. Thiscan give significant performance benefits at a small code size cost,but at the risk of a longer build time.

More aggressive inlining and automatic inliningfor-O3 -Otime.