4.3 Optimizing gcc Compilation (2024)

The software described in this documentation is either in Extended Support or Sustaining Support. See https://www.oracle.com/us/support/library/enterprise-linux-support-policies-069172.pdf for more information.
Oracle recommends that you upgrade the software described by this documentation as soon as possible.

The -O level option to gcc turns on compiler optimization, when the specified value of level has the following effects:

0

The default reduces compilation time and has the effect that debugging always yields the expected result. This level is equivalent to not specifying the -O option at all. However, a number of optimization options are still enabled, for example: -falign-loops, -finline-functions-called-once, and -fmove-loop-invariants.

1

The compiler attempts to reduce both the size of the output binary code and the execution speed, but it does not perform optimizations that might substantially increase the compilation time.

2

The compiler performs optimizations that do not require a tradeoff of space for speed. Compared to level 1, level 2 optimization improves the performance of the output binary but it also increases the compilation time.

3

The compiler turns on the -fgcse-after-reload, -finline-functions, -fipa-cp-clone, -fpredictive-commoning, -ftree-vectorize, and -funswitch-loops options, which require a tradeoff of space for speed, in addition to the level 2 optimizations.

s

The compiler optimizes to reduce the size of the binary instead of execution speed.

If you do not specify an optimization option, gcc attempts to reduce the compilation time and to make debugging always yield the result expected from reading the source code. If you enable optimization, the compiler tries to improve performance, to reduce the size of the output binary, or both, but compilation takes longer and you can lose the ability to debug the program effectively. If you compile several source files together to a single output binary file, the compiler uses information that it gathers from all of the source files when compiling each individual source file.

You can use the following command to find out which optimization options are enabled at a specified optimization level:

$ gcc -c -Q -Olevel --help=optimizers

To improve the speed of compilation, you can specify the -pipe option, which instructs gcc to use pipes rather than temporary files for communication between the various stages of compilation.

Taking advantage of hardware properties specific to target platforms can result in a significant performance improvement. By default, GCC compiles code that is optimized for the most processors. However, you can use the -mtune and -march options with gcc to optimize instruction scheduling and instruction set selection respectively. Specifying an architecture with -march implicitly selects the value of -mtune unless you specify a value explicitly. Your program can still run, albeit probably not optimally, if you specify an incorrect value for -mtune, but it is likely to fail if you specify an incorrect value for -march. For more information, see the gcc(1) manual page and the GCC 4.4.4 Manual: Hardware Models and Configurations.

Copyright © 2014, 2021, Oracle and/or its affiliates. Legal Notices

4.3 Optimizing gcc Compilation (2024)
Top Articles
AboutForex || Forex Spot Trading
7 Simple DIY Clothing Repairs That Will Save You Some Serious Money
English Bulldog Puppies For Sale Under 1000 In Florida
Katie Pavlich Bikini Photos
Gamevault Agent
Pieology Nutrition Calculator Mobile
Hocus Pocus Showtimes Near Harkins Theatres Yuma Palms 14
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Compare the Samsung Galaxy S24 - 256GB - Cobalt Violet vs Apple iPhone 16 Pro - 128GB - Desert Titanium | AT&T
Vardis Olive Garden (Georgioupolis, Kreta) ✈️ inkl. Flug buchen
Craigslist Dog Kennels For Sale
Things To Do In Atlanta Tomorrow Night
Non Sequitur
Crossword Nexus Solver
How To Cut Eelgrass Grounded
Pac Man Deviantart
Alexander Funeral Home Gallatin Obituaries
Shasta County Most Wanted 2022
Energy Healing Conference Utah
Aaa Saugus Ma Appointment
Geometry Review Quiz 5 Answer Key
Hobby Stores Near Me Now
Icivics The Electoral Process Answer Key
Allybearloves
Bible Gateway passage: Revelation 3 - New Living Translation
Yisd Home Access Center
Home
Shadbase Get Out Of Jail
Gina Wilson Angle Addition Postulate
Celina Powell Lil Meech Video: A Controversial Encounter Shakes Social Media - Video Reddit Trend
Walmart Pharmacy Near Me Open
Marquette Gas Prices
A Christmas Horse - Alison Senxation
Ou Football Brainiacs
Access a Shared Resource | Computing for Arts + Sciences
Vera Bradley Factory Outlet Sunbury Products
Pixel Combat Unblocked
Cvs Sport Physicals
Mercedes W204 Belt Diagram
Mia Malkova Bio, Net Worth, Age & More - Magzica
'Conan Exiles' 3.0 Guide: How To Unlock Spells And Sorcery
Teenbeautyfitness
Where Can I Cash A Huntington National Bank Check
Topos De Bolos Engraçados
Sand Castle Parents Guide
Gregory (Five Nights at Freddy's)
Grand Valley State University Library Hours
Holzer Athena Portal
Hello – Cornerstone Chapel
Stoughton Commuter Rail Schedule
Selly Medaline
Latest Posts
Article information

Author: Jerrold Considine

Last Updated:

Views: 6055

Rating: 4.8 / 5 (58 voted)

Reviews: 89% of readers found this page helpful

Author information

Name: Jerrold Considine

Birthday: 1993-11-03

Address: Suite 447 3463 Marybelle Circles, New Marlin, AL 20765

Phone: +5816749283868

Job: Sales Executive

Hobby: Air sports, Sand art, Electronics, LARPing, Baseball, Book restoration, Puzzles

Introduction: My name is Jerrold Considine, I am a combative, cheerful, encouraging, happy, enthusiastic, funny, kind person who loves writing and wants to share my knowledge and understanding with you.