GCC, compare the effect of using -O2 and using all the optimization flags it turns on

前端 未结 2 1506
一个人的身影
一个人的身影 2021-01-22 01:21

From gcc5.4 documentation, it says

-O2 turns on all optimization flags specified by -O. It also turns on the following optimization flags:

-ft

相关标签:
2条回答
  • 2021-01-22 01:25

    The optimisation level affects decisions in other parts of the compiler besides determining which passes get run. These can be during mandatory processes like transforming between internal representations of the code, register allocation etc, so the optimisation level is not exactly equivalent to a set of switches enabling every compiler pass. Look at this thread for some discussion on this topic.

    0 讨论(0)
  • 2021-01-22 01:33

    It is a common gotcha. In order to enable (or disable) specific optimizations, you must first enable the optimizer in general, i.e. use one of -O... flags, except -O0 (or just -O, which is equivalent to -O1).

    0 讨论(0)
提交回复
热议问题