D mentioned on Rust discussions site
Stefan Koch
uplink.coder at googlemail.com
Sat May 23 09:13:22 UTC 2020
On Saturday, 23 May 2020 at 09:03:38 UTC, NaN wrote:
> On Saturday, 23 May 2020 at 02:37:23 UTC, Walter Bright wrote:
>> On 5/22/2020 2:22 AM, Henrik wrote:
>>> do you find the ideas of the restrict keyword and VLA bad, or
>>> only the current implementation in C99?
>>
>> I've done some experiments with restrict in gcc, examined the
>> generated code, and found the optimizations it does and does
>> not do baffling. I wonder if perhaps it is used so little that
>> nobody really bothered to get the semantics right.
>
> There's a video on YouTube Chandler Caruth about how LLVM
> optimises C++, one of the interesting points he made was that
> const is literately zero help to the compiler for optimisation.
>
> He also said that inlining is the single most important
> optimisation.
He's right about const. As for inlining LLVM loves inlining.
It's not always the right choice.
The reason why it's deemed important is because it allows the
optimizer
to effectively see across function boundaries (since merging the
function bodies removes that.) And it can specialize the callee
code for the callers requirements.
However that can also lead to problems with code-size and
therefore i-cache stalls, (the worst kind of stalls). that said,
I-caches are pretty large these days to support out-of-order
execution. So maybe that's less of a problem running on modern
cpus.
On an embedded device you'll want to disable the inliner through
(which is what -Os or Oz) does.
More information about the Digitalmars-d
mailing list