4 ms·
"generally you want -O2" I see this a lot shouldn't O3 produce better optimizations? Is that people have large codebases? OR is it that O3 does some CPU/memory
by lephyrius 11y ago
"generally you want -O2"
I see this a lot shouldn't O3 produce better optimizations?
Is that people have large codebases? OR is it that O3 does some CPU/memory tradeoffs? OR something else?
- Avshalom 11y agowith out RTFA -O3 is where a lot of the weird compiler deciding it's smarter than you optimizations come in, and most of the time it is smarter than you and sometimes it introduces weird behavior. ALSO it generally produces a larger binary which means less of it fits in the cache. I know a while back it was often suggested to try O3 and OS because often OS ended up being faster.
- michael_h 11y agoSometimes -O3 produces slower code than -O2. Sometimes it produces incorrect code. I usually compile with -O2 and annotate certain functions with O3 - if it looks like vectorization will give the function a boost.