C++ Logo

std-proposals

Advanced search

Re: [std-proposals] this return type

From: Thiago Macieira <thiago_at_[hidden]>
Date: Sun, 09 Apr 2023 11:38:30 -0300
On Sunday, 9 April 2023 08:48:56 -03 Jan Schultke via Std-Proposals wrote:
> After discussing this with a few very well-versed people: you're most
> likely right and this is a missed optimization. In that code sample,
> the compiler could have used another callee-preserved register to save
> on moves from memory.

But is it worth it? There are relatively few callee-preserved registers, so
each one of them is precious and could be used to store something else. I
doubt a compiler would spill a memory location to the stack, even if it is to
benefit from processor techniques that assign registers to stack locations.
Meanwhile, the memory location is read-only and likely to be in the cache
because it was used by the callee anyway.

This is probably worth some benchmarking in real workloads, not micro-
benchmarks.

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

Received on 2023-04-09 14:38:32