C++ Logo

std-proposals

Advanced search

Re: [std-proposals] The real problems with optimizing C++ are not getting better

From: Avi Kivity <avi_at_[hidden]>
Date: Tue, 26 Aug 2025 14:15:27 +0300
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_at_[hidden]> 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.


Received on 2025-08-26 11:15:31