Sub-optimal code generated for certain calls to functions with auto ref qualified parameters
Per Nordlöw
per.nordlow at gmail.com
Mon Aug 10 11:24:36 UTC 2020
As a follow-up to recent discussions at
https://github.com/dlang/dmd/pull/11000
I wonder if the compiler generates sub-optimal code for functions
with `auto ref` parameters when passed l-values to parameters
whose type fit in registers.
For instance,
T square_nt(T)(immutable scope T x)
{
return x*x;
}
T square_t(T)(const auto ref scope T x)
{
return x*x;
}
@safe pure nothrow @nogc unittest
{
long x;
auto y = square_nt(x); // passed via register
auto z = square_t(x); // passed via indirection
}
According to my interpretation of
https://d.godbolt.org/z/5G4Eqn
it does.
More information about the Digitalmars-d
mailing list