| ▲ | 201984 an hour ago | |||||||||||||
What's your reason for -O2 over -O3? | ||||||||||||||
| ▲ | cogman10 an hour ago | parent | next [-] | |||||||||||||
Historically, -O3 has been a bit less stable (producing incorrect code) and more experimental (doesn't always make things faster). Flags from -O3 often flow down into -O2 as they are proven generally beneficial. That said, I don't think -O3 has the problems it once did. | ||||||||||||||
| ||||||||||||||
| ▲ | wavemode an hour ago | parent | prev | next [-] | |||||||||||||
You have to profile for your specific use case. Some programs run slower under O3 because it inlines/unrolls more aggressively, increasing code size (which can be cache-unfriendly). | ||||||||||||||
| ||||||||||||||
| ▲ | bluGill 31 minutes ago | parent | prev [-] | |||||||||||||
Most people use -O2 and so if you use -O3 you risk some bug in the optimizer that nobody else noticed yet. -O2 is less likely to have problems. In my experience a team of 200 developers will see 1 compiler bug affect them every 10 years. This isn't scientific, but it is a good rule of thumb and may put the above in perspective. | ||||||||||||||
| ||||||||||||||