On Monday, 31 January 2022 at 08:54:16 UTC, Patrick Schluter wrote:
-O3 often chooses longer code and unrollsmore agressively inducing higher miss rates in the instruction caches.
-O2 can beat -O3 in some cases when code size is important.

One of the historical reasons for favoring -O2 optimization level over -O3 was the necessity for Linux distributions to fit on a CD or DVD. Also if everyone is using -O2 optimizations, then -O3 optimizations get a lot less testing coverage and are more likely to have compiler bugs. This makes -O2 even more attractive for those, who prefer safety and stability...

I think that it's a good thing that LDC is breaking out of this -O2 vs. -O3 dilemma by just mapping "-O" option to -O3 ("aggressive optimizations"):

    Setting the optimization level:
      -O                                   - Equivalent to -O3
--O0 - No optimizations (default)
      --O1                                  - Simple optimizations
      --O2                                  - Good optimizations
--O3 - Aggressive optimizations
      --O4                                  - Equivalent to -O3
      --O5                                  - Equivalent to -O3
--Os - Like -O2 with extra optimizations for size --Oz - Like -Os but reduces code size further

I wonder if GDC can do the same?

Reply via email to