当前位置:网站首页>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
边栏推荐
- Build your own application based on Google's open source tensorflow object detection API video object recognition system (I)
- Soft exam information system project manager_ Project set project portfolio management --- Senior Information System Project Manager of soft exam 025
- MySQL数据库(五)视 图 、 存 储 过 程 和 触 发 器
- [pointer] solve the last person left
- Réponses aux devoirs du csapp 7 8 9
- 刷视频的功夫,不如看看这些面试题你掌握了没有,慢慢积累月入过万不是梦。
- Statistics 8th Edition Jia Junping Chapter 4 Summary and after class exercise answers
- DVWA exercise 05 file upload file upload
- The minimum number of operations to convert strings in leetcode simple problem
- MySQL development - advanced query - take a good look at how it suits you
猜你喜欢
Fundamentals of digital circuits (III) encoder and decoder
Servlet
全网最详细的postman接口测试教程,一篇文章满足你
C language do while loop classic Level 2 questions
ucore lab8 文件系统 实验报告
Investment operation steps
UCORE lab1 system software startup process experimental report
China's county life record: go upstairs to the Internet, go downstairs' code the Great Wall '
软件测试行业的未来趋势及规划
How to rename multiple folders and add unified new content to folder names
随机推荐
Common Oracle commands
Software testing interview summary - common interview questions
CSAPP homework answers chapter 789
[200 opencv routines] 98 Statistical sorting filter
Leetcode simple question: check whether the numbers in the sentence are increasing
pytest
Wang Shuang's detailed notes on assembly language learning I: basic knowledge
HackTheBox-Emdee five for life
Should wildcard import be avoided- Should wildcard import be avoided?
C language do while loop classic Level 2 questions
Cc36 different subsequences
{1,2,3,2,5} duplicate checking problem
Pedestrian re identification (Reid) - data set description market-1501
If the position is absolute, touchablehighlight cannot be clicked - touchablehighlight not clickable if position absolute
Global and Chinese market of maleic acid modified rosin esters 2022-2028: Research Report on technology, participants, trends, market size and share
[pointer] counts the number of times one string appears in another string
Sleep quality today 81 points
[HCIA continuous update] working principle of static route and default route
Wang Shuang's detailed learning notes of assembly language II: registers
What is an index in MySQL? What kinds of indexes are commonly used? Under what circumstances will the index fail?