https://gcc.gnu.org/bugzilla/show_bug.cgi?id=100323
Richard Biener <rguenth at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |hubicka at gcc dot gnu.org Last reconfirmed| |2021-04-29 Status|UNCONFIRMED |NEW Keywords| |missed-optimization Ever confirmed|0 |1 --- Comment #1 from Richard Biener <rguenth at gcc dot gnu.org> --- Note in your example 'f' is compiled with -O0 so it wouldn't be inlined because there's a mismatch in optimize options. But the real problem is that IPA and early inlining look at the global 'optimize' and -finline settings. For the early inliner that's possible to fix. Fixed testcase: __attribute__ ((optimize (2))) static int f (void) { return 0; } __attribute__ ((optimize (2))) int g (void) { return f (); } #pragma GCC optimize ("2") int h (void) { return f (); }