Get Assembly code after every optimization GCC makes?

前端 未结 7 2069
不知归路
不知归路 2020-12-19 00:19

From Optimization Compiler on Wikipedia,

Compiler optimization is generally implemented using a sequence of optimizing transformations

7条回答
  •  清酒与你
    2020-12-19 00:59

    Compile with switch -S to get the assembly code. This should work for any level of optimization. For instance, to get the assembly code generated in O2 mode, try:

        g++/gcc -S -O2 input.cpp
    

    a corresponding input.s will be generated, which contains the assembly code generated. Repeat this for any optimization level you want.

提交回复
热议问题