Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7943 Discussions

how is decided what goes into -O1,-O2-,-O3?

Hoste__Kenneth
Beginner
334 Views
Hello,

I have a question which is slighty related to http://softwareforums.intel.com/en-us/forums//topic/51526.

The documentation on the -Ox optimization flags mention that each flag has a certain purpose, i.e. fast compilation, a fast running binary, etc...

How is decided which optimization goes where? I it just extensive testing, or is some kind of decision framework used?



Kenneth Hoste
ELIS - Ghent University
kenneth.hoste@elis.ugent.be
http://www.elis.ugent.be/~kehoste
0 Kudos
3 Replies
TimP
Honored Contributor III
334 Views
I think there is an accepted tradition, where compile time spent on detailed optimization increases with O level. For a given application, if you are not familiar with it, you would have to test to find out to what extent the increased optimization pays off in faster execution.
Efforts have gone into recent revisions of Intel compilers to make -O1 a useful performance option for certain applications. In those cases, the size of generated code may be much smaller with -O1 than with -O2. So, in that case, you could say that the decision was made in response to customer needs.
0 Kudos
Hoste__Kenneth
Beginner
334 Views
I understand why the -Ox flags are present, but I was wondering *how* is decided which optimizations go where?
I.e., when does a particular optimization pass produce enough benefit performance-wise to justify it's presence in -O1 for example?

Is it just extensive testing on a database of programs, is it pure reasoning, or some combination of both?
0 Kudos
TimP
Honored Contributor III
334 Views
While I can't speak for the compiler team, I'm certain the optimizations have to show a benefit on various benchmarks, SPEC getting the most weight for -O3. -O1 is more of a compromise between run-time performance, compile time, and code size. -Os considers code size as the most important factor.
0 Kudos
Reply