Optimisation possibilities: current, future and enhancements
kinke via Digitalmars-d
digitalmars-d at puremagic.com
Thu Aug 25 10:22:27 PDT 2016
I found it hard to believe LDC generates such crappy code when
optimizing. These are my results using LDC master on Win64 (`ldc2
-O -release -output-s`):
struct Foo
{
immutable _u = 8;
int foo() const
{
return 8 * _u;
}
}
int use(ref const(Foo) foo)
{
return foo.foo() + foo.foo();
}
int main()
{
Foo f;
return use(f);
}
_D7current3Foo3fooMxFZi:
movl (%rcx), %eax
shll $3, %eax
retq
_D7current3useFKxS7current3FooZi:
movl (%rcx), %eax
shll $4, %eax
retq
_Dmain:
movl $128, %eax
retq
Sure, Foo.foo() and use() could return a constant, but otherwise
it can't get much better than this.
More information about the Digitalmars-d
mailing list