“Since my good old Pentium 166 days, I’ve liked to search for the best optimizations possible so programs can take the maximum advantage of hardware/CPU cycles. If I have a nice piece of hardware, why not run it at its full power, using every little feature? Shouldn’t we all try to get the best results from the money invested in our machines?” Read the article at FreshMeat.
1) -msse -msse2 -mmmx: Only useful if you don’t use the -march=xxx, which implies it.
2) -mfpmath=sse. Can be useful on pentium4, makes all FPU math use the SSE registers, which can be a bit faster.
I always thought -O69 was faster than -O3….. stupid #*^&%$ #linux guys…
but that not a problem. I do find the article a bit short, I would have liked to have some eexplanations on some of the optimisation techniques.
Some of the comments are really good.
—
http://homepage.mac.com/softkid
From my experience on Linux with gcc …
I always get plenty of errors on optimizing software (I have no big experience on it, I have given up – and used many pre-compiled distribution binaries instead, mainly I tried blender, lyx and Mozilla sources) …
(Sometimes less with intel free compiler 6, but that’s another story, better and simpler docs also …)
(L. Hirlimann really should try Linux english aspell ot ispell
According to this article, many developers don’t seem to read gcc documentation at all. A couple of projects that I know are very dependant on optimization, Lame and MPlayer, use wrong, non-existant, or reduntant optimizations just about all of the time. What’s up with that?
According to this article, many developers don’t seem to read gcc documentation at all. A couple of projects that I know are very dependant on optimization, Lame and MPlayer, use wrong, non-existant, or reduntant optimizations just about all of the time. What’s up with that?
Yeah, I agree.. One time, I sent an email to a developer about it in the past with the proof of gcc documentation link. The developer just doesn’t listen or believe, so I leave him alone.
As GCC has gotten more mature, I think the optimization options have simplified a lot. A lot of these developers got used to gcc back around the early GCC 2.x series, so they’re in the habit of using these optimizations. As long as it’s not hurting anything, I don’t t hink it should be a problem.
To Chicobaud> I compiled my entire distro at -march=pentium4 -mfpmath=sse -O3 (pretty heavy optimization) with nary an error. The early 3.x series was kind of flaky (3.0 and 3.1) but 3.2 seems quite mature. But you’re right, ICC 7.x handles optimization a bit better.
Compilers very seldom cause bugs when optimizing, normally it is because optimization takes advantage of all the things the language guarantees which breaks a non-standard program very fast. Writing completely correct C and C++ programs is quite a bit trickier than making one that works in “normal” cases.
“stupid #*^&%$ #linux guys…”
Are you trying to be funny or are you just some sort of zealot for another OS?
That was a joke dude.
Can you give an example of a piece of code that works with no optimization but fails with optimization on? Surely ANY optimization translation as a rule should not break the functionality of the code.
It seems to me that the gcc optimization flags have been a moving target for a while. I wish someone would start up a website that exhaustively collects stats about gcc compilations and such using different flags and good rule of thumb flags to use for debug builds vs production builds for different target platforms.
It’s not that the opimization “breaks” the code, its that the optimization can expose bugs which you might get away with with optimizations turned off.
For example if one of your buffers is overflowing on an unoptimized build, the memory location after the buffer might not contain anything important, so your program continues to run. If on an optimized build that memory location is important to your program, is isn’t even allocated to your program, the program will crash or do something bad.
Of course, this can go the other way. Perhaps in the unoptimized build something important is in that memory location, and its not in the optimized build.