[Issue 13381] One case of array literal that can be stack-allocated
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Sun Aug 31 04:00:06 PDT 2014
https://issues.dlang.org/show_bug.cgi?id=13381
--- Comment #6 from bearophile_hugs at eml.cc ---
(In reply to yebblies from comment #5)
> Ideally the optimizer would do this by itself, once the literal is
> stack-allocated. I suspect it already does in some cases for gdc/ldc.
If I compile this program:
bool foo(in int[] a) {
return a == [1, 2, 3];
}
void main() {}
With the latest ldc2 with:
ldmd2 -O -release -inline -noboundscheck -output-s test.d
The asm of foo is:
__D4test3fooFxAiZb:
subl $20, %esp
movl $3, 4(%esp)
movl $__D12TypeInfo_xAi6__initZ, (%esp)
calll __d_newarrayvT
movl $3, 8(%edx)
movl $2, 4(%edx)
movl $1, (%edx)
movl %edx, 12(%esp)
movl %eax, 8(%esp)
movl 28(%esp), %eax
movl %eax, 4(%esp)
movl 24(%esp), %eax
movl %eax, (%esp)
movl $__D12TypeInfo_Axi6__initZ, 16(%esp)
calll __adEq2
testl %eax, %eax
setne %al
addl $20, %esp
ret $8
--
More information about the Digitalmars-d-bugs
mailing list