Automatically find compiler options for fastest exe on given machine?

Posted by dehmann on Stack Overflow See other posts from Stack Overflow or by dehmann
Published on 2010-03-14T18:33:41Z Indexed on 2010/03/14 18:45 UTC
Read the original article Hit count: 381

Is there a method to automatically find the best compiler options (on a given machine), which result in the fastest possible executable?

Naturally, I use g++ -O3, but there are additional flags that may make the code run faster, e.g. -ffast-math and others, some of which are hardware-dependent.

Does anyone know some code I can put in my configure.ac file (GNU autotools), so that the flags will be added to the Makefile automatically by the ./configure command?

In addition to automatically determining the best flags, I would be interested in some useful compiler flags that are good to use as a default for most optimized executables.

© Stack Overflow or respective owner

Related posts about c++

Related posts about optimization