On Tue, 26 Aug 2025 at 12:15, Avi Kivity <avi@scylladb.com> wrote:
On Tue, 2025-08-26 at 11:01 +0100, Jonathan Wakely via Std-Proposals wrote:


On Mon, 25 Aug 2025 at 02:12, Adrian Johnston via Std-Proposals <std-proposals@lists.isocpp.org> 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.

Yes, the abstraction penalty is not zero, but it's much lower than it was 15-20 years ago, let alone 30 years ago.

Early inlining also made a difference for GCC.