On Tue, 2025-08-26 at 11:01 +0100, Jonathan Wakely via Std-Proposals wrote:
Hello,
(If you spend a lot of time looking at generated assembly you might
want to skip this one.)
As we all know the compiler's budget for optimizing C++ is an
implementation-defined metric where it knows best what is needed and
we are not supposed to be doing the compiler's job for it.
Unfortunately, this view has never really worked well in practice.
Recently I spent some time looking at the generated assembly from gcc
and clang and it doesn't look like the situation has improved in 30
years.
This is nonsense.
Optimizations like autovectorization and conditional devirtualization do lots that wasn't possible 30 years ago. A problem is that many programs are much bigger than they were 30 years ago.
IIUC, the big leap came with Scalar Reduction of Aggregates (SRA). Small structs can now be broken up intro their constituent scalars, each of which can be allocated registers separately, spilled to their stack separately, and have their lifetimes tracked separately. IIRC it was directly intended to reduce the C++ abstraction cost.