News for hackers. Stuff that matters.
Re:GCC x86 Performance Hints (2012) by gnufx on Friday August 21, 2020 @06:26PM (#24239517)
> >"-Ofast" same as "-O3 -ffast-math"

That depends on the language and the GCC version.

> -ffast-math makes the compiler violate IEEE, it would make a very bad default.

Yes, but unfortunately it's the Intel default, which contributes to some of the compiler mythology.

Regarding unrolling, you usually do want it in numeric loops, and -O3 unrolls (and jams) as -fopt-info shows.

Re:GCC x86 Performance Hints (2012) by simias on Saturday August 22, 2020 @07:23AM (#24243394)
>That depends on the language and the GCC version.

I was quoting TFA verbatim. I actually never use -Ofast myself, beyond -O3 I tend to use the individual flags manually, checking wit benchmarks that it makes a difference.

>Yes, but unfortunately it's the Intel default, which contributes to some of the compiler mythology.

I didn't know that. I guess Intel is extremely performance-oriented and doesn't really care for portability so it makes some sense for them to do that.

>Regarding unrolling, you usually do want it in numeric loops, and -O3 unrolls (and jams) as -fopt-info shows.

Sure but that's to my point: the default optims for -O3 are fairly aggressive already. Unless you're writing code where performance is absolutely critical you'll probably be do just fine just remembering to pass "-Wall -O3" to GCC and that's it. Actually for most of my code where I want good performance but I'm not counting individual clock cycles I tend to default to -O2 which gives you most of the performance benefits with more conservative and easier to debug optimizations.

And for cases where you need to go beyond -O3 you'll probably have to write some benchmarking code before you can decide which additional option to use. At least, in my experience.