Achieving O0 performance by disabling O1 level optimizations
Eric Botcazou
ebotcazou@libertysurf.fr
Tue Dec 16 23:51:05 GMT 2025
> I would greatly appreciate any guidance on the following:
>
>
> - Are there optimization-related behaviors at -O1 that are controlled
> implicitly (e.g., via internal optimize > 0 gating or other non-flag
> mechanisms)?
> - Is it expected that -O0 behavior cannot be fully reproduced by
> disabling flags starting from -O1?
> - Are there additional factors that significantly differentiate -O1 from
> -O0, and can I redirect those properties while transitioning from O1 to
> O0?
> - Can I implement any flag that will redirect to O0 properties even if
> I run O1 with all defined disable flags?
There are global variables (optimize, optimize_debug, optimize_fast and
optimize_size) directly set by the -Ox switches, in combination with others.
So no -Ox switch can be reduced to a simple combination of -f switches, and
that's indeed particularly visible for -O1 vs -O0. We already have way too
many -f switches in GCC, so I'm not sure that more of them would be welcome.
--
Eric Botcazou
More information about the Gcc
mailing list