C++ Logo

std-proposals

Advanced search

Re: [std-proposals] this return type

From: Jan Schultke <janschultke_at_[hidden]>
Date: Sun, 9 Apr 2023 13:48:56 +0200
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.

I'm not sure whether this is done intentionally, since it looks like
the LLVM IR doesn't have enough information to make that optimization,
so the problem stems from the frontend.

Perhaps this is to ensure compatibility with when semantics were
different in C++98, or pre-standard, but I can't say for sure and
don't have access to the original standard.

Cheers,
Jan

Received on 2023-04-09 11:49:08