Deploying gcc Compiler Optimization

I'm interested in the code in which gcc actually optimized the code. Is there any way I could do?

I looked at several other similar quests, I tried several things,

  • -Wa, ahl = filename.lst: - this option is really good, you can view the code and the corresponding machine code, but it is not good when I enable the O3 option.
  • Optimized dumping tree: - I'm sure gcc gives me a lot of debugging information. But I can’t decrypt it. I will be glad if someone can point out any information available.

Is there any other better way to figure out which part of gcc code is optimized?

Thanks Madhur

+4
source share
2 answers

You can compile the code twice, first with

$ gcc -O0 -S -o yourfile_o0.s 

Then with:

 $ gcc -O3 -S -o yourfile_o3.s 

Then you can diff get two resulting assembly files:

 $ diff -u yourfile_o0.s yourfile_o3.s $ vim -d yourfile_o0.s yourfile_o3.s $ emacs --eval '(ediff "yourfile_o0.s" "yourfile_o3.s")' 
+8
source

Look at the member code or decompile the compiled application. C decompilers produce ugly C code, but to analyze which code was generated, it should be sufficient.

0
source

All Articles