Re: O2 flag in compilation

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 23, 2001 at 09:54:49AM -0700, Christine Ames wrote:
> Snipped from "man gcc":

I hope you realise that the gcc manual page is NOT the authorative
reference. The gcc info files are authorative.

> -O2
> Optimize even more. Nearly all supported optimizations that do not involve a
> space-speed tradeoff are performed. Loop unrolling and function inlining are
> not done, for example. As compared to -O, this option increases both
> compilation time and the performance of the generated code.

The most important is the compiler uses -finline in this particular
case, so it does indeed pay attention to the 'inline' keyword. Without
that, it won't and that's exactly the reason why modules compiled
without -O2 fail to link or load.

> -O3
> Optimize yet more. This turns on everything -O2 does, along with also
> turning on -finline-func*- tions.

And it also enables -funroll-all-loops which isn't too smart. In most
of the cases -O3 actually generates *slower* code than -O2 because
unrolling all loops makes the code larger so it won't fit in the
I-cache anymore. To give you an idea how expensive a cache miss is: on
StrongARM CPU a single cache miss costs you about 60 cycles.

-Os is also interesting, it optimises for size. The ARM gcc compiler
will still compile correct kernels, I don't know what will happen with
other architectures. An intersting sidenote is that -Os sometimes even
generates faster code than -O2, because the code fits better in the
I-cache.


Erik

-- 
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031,  2600 GA Delft, The Netherlands
Phone: +31-15-2783635  Fax: +31-15-2781843  Email: J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux