cintelcompiler-optimizationicc

Intel icc: how to dump optimized code as C file


Gcc's -fdump-tree-optimized option dumps an optimized version of your C code as a C file. Is there a way I can do the same using intel's icc compiler?

I have a matrix multiplication code that I have compiled as icc -O3 -ipo mult.c. I want to view how the compiler has performed optimizations. If nothing works, then I shall generate the assembly code for the program.


Solution

  • Technically, -fdump-tree-optimized don't dump a C representation, but a textual partial representation of the Gimple code used inside GCC (Gimple is the middle-end internal representation of instructions, on which most GCC target-independent optimization passes operate).

    But icc is a proprietary compiler (a black box), so from the point of view of its provider, it is not interesting (for Intel) to show how icc works.

    GCC has the ability to show its internal representations, because it is a free software. Proprietary compilers don't want to show how they work.

    If this is a class, you could perhaps try also LLVM. (But I don't know how do dump internal representations inside).

    And more importantly, if this is a class, you might suggest your student using GCC 4.6 to develop a plugin or a GCC MELT extension to explore and experiment optimizations. MELT is a high-level domain specific language to extend GCC and it provides many features to ease such tasks.