Effects of Compiler Optimization (-O3 -O2 -O1 -O0) on code

This forum is aimed at students with little or no programming experience. It aims to provide students with an understanding of the role computation can play in solving problems.
Forum rules
This forum aims to provide material related to computer programming languages, tools and designs.

Effects of Compiler Optimization (-O3 -O2 -O1 -O0) on code

Unread postby Tassadaq Cheema » Thu Aug 15, 2013 2:05 am

-O1 Optimize. Optimizing compilation takes somewhat more time, and a lot more memory for a large function.

-O2 Optimize even more. GCC performs nearly all supported optimizations that do not involve a space-speed tradeoff. The compiler does not perform loop unrolling or function inlining when you specify -O2. As compared to -O, this option increases both compilation time and the performance of the generated code.

-O3 Optimize yet more. -O3 turns on all optimizations specified by -O2 and also turns on the -finline-functions, -funswitch-loops, -fpredictive-commoning, -fgcse-after-reload and -ftree-vectorize options.

-O0 Reduce compilation time and make debugging produce the expected results. This is the default.

-Os Optimize for size. -Os enables all -O2 optimizations that do not typically increase code size. It also performs further optimizations designed to reduce code size.
User avatar
Tassadaq Cheema
 
Posts: 67
Joined: Tue Jul 03, 2012 1:41 am
Location: Barcelona
Has thanked: 5 times
Been thanked: 5 times

Re: Effects of Compiler Optimization (-O3 -O2 -O1 -O0) on co

Unread postby shaddisi23 » Tue Jan 28, 2014 1:11 pm

Optimizing accumulation takes somewhat added time, and a lot added amnesics for a ample function.

-O2 Optimize even more. GCC performs about all accurate optimizations that do not absorb a space-speed tradeoff. The compiler does not accomplish bend unrolling or action in lining if you specify -O2. As compared to -O, this advantage increases both accumulation time and the achievement of the generated code.

-O3 Optimize yet more. -O3 turns on all optimizations defined by -O2 and as well turns on the -finline functions, -fun witch-loops, -fpredictive-commoning, -focused-after-reload and -free-vectorize options.
User avatar
shaddisi23
 
Posts: 7
Joined: Fri Jan 17, 2014 12:18 pm
Has thanked: 0 time
Been thanked: 0 time


Return to Computer Sciences & Programming

Who is online

Users browsing this forum: No registered users and 2 guests

cron