gcc - compiler options to increase optimization performance of the code -


i porting code intel architecture arm architecture. same code trying build arm cross compilers on centos. there compiler options increase performance of executable image because image on intel might not give similar performance on arm. there way achieve this?

a lot of optimization options exist in gcc. default compiler tries make compilation process short possible , produce object code makes debugging easy. however, gcc provides several options optimization.

four general levels of incremental optimizations performance available in gcc , can activated passing 1 of options -o0, -o1, -o2 or -o3. each of these levels activates set of optimizations can activated manually specifying corresponding command line option. instance -o1 compiler performs branches using decrement , branch instruction (if available , applicable) rather decrementing register, comparing 0 , branching in separate instructions. decrement , branch can specified manually passing -fbranch-count-reg option. consider optimizations performed @ each level depend on target architecture, can list of available , enabled optimization running gcc -q --help=optimizers option.

generally speaking levels of optimization correspond (notice @ each level optimization of previous ones applied):

  • -o0: default level, compiler tries reduce compilation time , produce object code can processed debugger
  • -o1: compiler tries reduce both code size , execution time. optimizations not take lot of compile time performed. compilation may take considerably more memory.
  • -o2: compiler applies optimizations available not affect code size. compiling takes more performance should improve.
  • -o3: compiler applies optimization might increase code size (for instance inlining functions)

for detailed description of optimization options can have here.
general remark consider compiler optimization designed work in general case effectiveness depend lot on both program , architecture running on.

edit:
if interested in memory paging optimization there -freorder-blocks-and-partition option (activated -o2). option reorders basic blocks inside each function partition them in hot blocks (called frequently) , cold blocks (called rarely). hot blocks placed in contiguous memory locations. should increasing cache locality , paging performance.


Comments

Popular posts from this blog

How has firefox/gecko HTML+CSS rendering changed in version 38? -

javascript - Complex json ng-repeat -

jquery - Cloning of rows and columns from the old table into the new with colSpan and rowSpan -