What would be the best settings for my CFLAGS and would it really matter? I'm using the default CFLAGS:
Code: Select all
CFLAGS="-02" -march=pentium3 -fomit-frame-pointer
CHOST="i686-pc-linux-gnu"
CXXFLAGS="${CFLAGS}"
Code: Select all
CFLAGS="-02" -march=pentium3 -fomit-frame-pointer
CHOST="i686-pc-linux-gnu"
CXXFLAGS="${CFLAGS}"

I would quote the entire CFLAGS string, not just "-O2" and add -pipe.pablolo wrote:Hello, I'm using a Pentium III Coppermine 797 Mhz.
What would be the best settings for my CFLAGS and would it really matter? I'm using the default CFLAGS:thanksCode: Select all
CFLAGS="-02" -march=pentium3 -fomit-frame-pointer CHOST="i686-pc-linux-gnu" CXXFLAGS="${CFLAGS}"
Code: Select all
CFLAGS="-02" -march=pentium3 -fomit-frame-pointerCode: Select all
CFLAGS="-02 -march=pentium3 -fomit-frame-pointer -pipe"Neither loop unrolling nor inlining functions are machine independent.jbannon wrote:In general, so long as you stick to applying machine--independent optimisations such as unroll-loops and inline-funtions, GCC is pretty safe, although these two might generate big executables, but the more aggressive optimisations (> O2 and fastmath) should be avoided as they're much too brittle for general use. GCC, whilst a good compiler suite, isn't a world beater when it comes to aggressive optimisations.
-O3 bloats your binaries and the small speed gains it gives is usually not worth it.greasy_grasshopper wrote:Your CFLAGS are fine. The only thing you can add to it is "-pipe", I think this will speed up compiling by not making any temporary files. Too much optimizations will break your system. I'm not really sure what's wrong with "-O3", but some people say that it's not worth it.
EDIT:typo
Huh? I hate to question a developer but can you please explain to me why they're not machine-independent? Every book on compiler design I have, and I have a few, lists these as candidates for machine-independent optimisation. For example, inlining is just macro-expansion with the difference that it follows the scope and visibility rules, guarantees that all side-effects in the arguments have taken place prior to expansion and that each argument is evaluated exactly once - no machine-dependent steps needed there. Indeed, you can do this in the source code if you're careful and the same applies with loop unrolling. Whether or not you would routinely do this during development is quite another matter. Similar optimisations can be done with arrays - no machine-dependent manipulations required to transform array indexing into pointer manipulation. All of these are certainly language-dependent and will result in different assembler output on different architectures but they can be, and typically are, performed before the back-end is even called to generate the actual target instructions. fastmath is a different matter because it relies on direct use of maths coprocessor instructions.ciaranm wrote:Neither loop unrolling nor inlining functions are machine independent.jbannon wrote:In general, so long as you stick to applying machine--independent optimisations such as unroll-loops and inline-funtions, GCC is pretty safe, although these two might generate big executables, but the more aggressive optimisations (> O2 and fastmath) should be avoided as they're much too brittle for general use. GCC, whilst a good compiler suite, isn't a world beater when it comes to aggressive optimisations.
You're forgetting register windowing. On some architectures, inlining certain things is less efficient because you've got to manually shove a load of registers onto the stack rather than just shifting windows. So a decent compiler will have special handling for architectures for which this applies.jbannon wrote:Huh? I hate to question a developer but can you please explain to me why they're not machine-independent? Every book on compiler design I have, and I have a few, lists these as candidates for machine-independent optimisation. For example, inlining is just macro-expansion with the difference that it follows the scope and visibility rules, guarantees that all side-effects in the arguments have taken place prior to expansion and that each argument is evaluated exactly once - no machine-dependent steps needed there.
Except that some CISC architectures have special loop handling tricks which mean you might not want to unroll certain kinds of tight loop -- a decent compiler knows about these.Indeed, you can do this in the source code if you're careful and the same applies with loop unrolling.