当前位置:网站首页>Brief description of compiler optimization level
Brief description of compiler optimization level
2022-07-06 15:09:00 【eric_ [email protected]】
Compile optimization , It will make the compiler try at the expense of compilation time and the ability to debug the program , To improve performance or code size ;
Reasonable optimization level , Can be in code volume 、 Executive performance 、RAM Get a balance in share !
https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
1、 Optimization level description
GCC The optimization level is -O0、-O1、-O2、-O3、-Og、-Os、-Ofast
Summarized below :
Optimization level | explain | remarks |
---|---|---|
-O0 | Turn off all optimizations | Code space is big , Inefficient execution -O1 The basic optimization level compiler does not spend too much compilation time , Try to generate faster 、 Smaller code |
-O2 | O1 Upgraded version , Recommended optimization level | The compiler tries to improve code performance , Without increasing the volume and taking up too much compilation time |
-O3 | The most dangerous optimization level | It will prolong the code compilation time , Generate larger volume 、 More memory consuming binary files , Greatly increase the probability of compilation failure and unpredictable program behavior , Do more harm than good |
-Og | O1 On the basis of , Eliminate optimizations that affect debugging | If the final purpose is to debug the program , You can use this parameter . But this parameter alone is not enough , This parameter just tells the compiler , The compiled code should not affect debugging , But the generation of debugging information still depends on -g Parametric |
-Os | O2 On the basis of , Further optimize code size | Eliminate optimizations that will increase the size of the final executable , If you want a smaller executable , This parameter can be selected . |
-Ofast | Optimize to the point that destroys standard compliance ( Equivalent to -O3 -ffast-math ) | Is in -O3 On the basis of , Added some unconventional optimizations , These optimizations are made by breaking some international standards ( For example, the implementation standards of some mathematical functions ) To achieve , Therefore, this parameter is generally not recommended . |
give an example :
2、MDK Optimization level modification
Set the optimization level globally
Set the optimization level locally
Usually , As the code structure is complex , The addition of third-party components , The overall optimization level can no longer meet the actual use scenarios ;
MDK It can be applied to a single file , Or set the optimization level separately for a single group of files .
- Set the optimization level in the code
In the code , Set the optimization level separately for a function
https://www.keil.com/support/man/docs/armcc/armcc_chr1359124988971.htm
AC5 Setting method in :
#pragma push
#pragma O1
void function(void){
... // Optimized at O0
}
#pragma pop
AC6 Setting method in :
void function(void) _attribute__((optnone))
{
... // Optimized none
}
Reference resources :
https://www.cnblogs.com/armfly/p/15605027.html
版权声明
本文为[eric_ [email protected]]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/02/202202131323057796.html
边栏推荐
- pytest
- Global and Chinese markets of cobalt 2022-2028: Research Report on technology, participants, trends, market size and share
- Cadence physical library lef file syntax learning [continuous update]
- Statistics 8th Edition Jia Junping Chapter 2 after class exercises and answer summary
- Réponses aux devoirs du csapp 7 8 9
- Wang Shuang's detailed notes on assembly language learning I: basic knowledge
- Cc36 different subsequences
- ucore lab6 调度器 实验报告
- The salary of testers is polarized. How to become an automated test with a monthly salary of 20K?
- Fundamentals of digital circuits (II) logic algebra
猜你喜欢
如何成为一个好的软件测试员?绝大多数人都不知道的秘密
软件测试工作太忙没时间学习怎么办?
Report on the double computer experiment of scoring system based on 485 bus
Summary of thread implementation
STC-B学习板蜂鸣器播放音乐2.0
[Ogg III] daily operation and maintenance: clean up archive logs, register Ogg process services, and regularly back up databases
CSAPP家庭作业答案7 8 9章
How to transform functional testing into automated testing?
China's county life record: go upstairs to the Internet, go downstairs' code the Great Wall '
“Hello IC World”
随机推荐
后台登录系统,JDBC连接数据库,做小案例练习
Investment operation steps
The four connection methods of JDBC are directly coded
[oiclass] maximum formula
Function: string storage in reverse order
UCORE lab1 system software startup process experimental report
Expanded polystyrene (EPS) global and Chinese markets 2022-2028: technology, participants, trends, market size and share Research Report
Transplant hummingbird e203 core to Da Vinci pro35t [Jichuang xinlai risc-v Cup] (I)
[pointer] find the value of the largest element in the two-dimensional array
软件测试有哪些常用的SQL语句?
Global and Chinese market of maleic acid modified rosin esters 2022-2028: Research Report on technology, participants, trends, market size and share
Nest and merge new videos, and preset new video titles
Capitalize the title of leetcode simple question
Statistics 8th Edition Jia Junping Chapter 4 Summary and after class exercise answers
DVWA exercise 05 file upload file upload
Mysql的事务
想跳槽?面试软件测试需要掌握的7个技能你知道吗
What level do 18K test engineers want? Take a look at the interview experience of a 26 year old test engineer
UCORE lab7 synchronous mutual exclusion experiment report
自动化测试你必须要弄懂的问题,精品总结