C++ Logo

std-proposals

Advanced search

Re: [std-proposals] [External Email] Std-Proposals Digest, Vol 52, Issue 17

From: Thiago Macieira <thiago_at_[hidden]>
Date: Wed, 05 Jul 2023 21:44:32 -0700
On Wednesday, 5 July 2023 21:06:20 PDT Sebastian Wittmeier via Std-Proposals
wrote:
> silent_at has 19 instructions in the _hot_ code path, EH has 21
> instructions.
>
> The only difference is that EH creates a stack frame.
>
>
> The creation of the stack frame could probably be optimized away in this
> example (but this is an optimization opportunity for gcc, not for the
> standard).

Yes, GCC could optimise away the creation of the stack frame to the cold path.
But do note that the function in question is also a candidate for inlining, at
which point there's no stack frame in the first place.

Even if it won't do any of that, the manipulation of the stack frame will run
in parallel to the other instructions, since there's no control or data
dependency. The impact will be that you have two more instructions to retire,
but unless your code is so efficient that it's already limited by the number of
instructions retired per cycle, you won't notice a thing. And the latter is
only possible if the memory loads were forwarded from very recent stores and
thus didn't cause a stall waiting for the L1 data cache.


-- 
Thiago Macieira - thiago (AT) macieira.info - thiago (AT) kde.org
   Software Architect - Intel DCAI Cloud Engineering

Received on 2023-07-06 04:44:33