https://gcc.gnu.org/bugzilla/show_bug.cgi?id=118570
Alexander Monakov <amonakov at gcc dot gnu.org> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |amonakov at gcc dot gnu.org --- Comment #2 from Alexander Monakov <amonakov at gcc dot gnu.org> --- -O2 trivializes the benchmark by discovering that 'romberg' is const without inlining it, then moving it out of the loop; -O3 inlines it, and I think uses of stack arrays make it difficult to passes like loop invariant motion to optimize it. I wouldn't expect this to be a big issue for real-world code: either the function wouldn't be called with the same arguments in the loop, or if it was a "proper" benchmark there would be compiler barriers in place to prevent the compiler from discovering the redundancy.