https://gcc.gnu.org/bugzilla/show_bug.cgi?id=114215
Andrew Pinski <pinskia at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Ever confirmed|0 |1 Status|UNCONFIRMED |WAITING Last reconfirmed| |2024-03-03 --- Comment #2 from Andrew Pinski <pinskia at gcc dot gnu.org> --- checkedvector::value_type& checkedvector::operator[](size_type)/167 call is unlikely and code size would grow freq:1.00 loop depth: 0 size: 4 time: 13 callee size: 6 stack: 0 op1 is compile time invariant If I had: ``` void test_demovector(checkedvector& vec, int x) noexcept { for(int i = 0; i < y; i++) vec[i]=5; } ``` Then GCC will inling operator[]: checkedvector::value_type& checkedvector::operator[](size_type)/167 inlined freq:8.09 Stack frame offset 0, callee self size 0 void __builtin_trap()/205 function body not available freq:0.00 loop depth: 1 size: 1 time: 1 I am suspecting this is the right heurstic. Do you have real code where the inlining does not happen at -Os/-Oz or you just looking at the code generation with code that might be benchmarking things?