Bug 11345 – Optimize array literal to static array assignment to not allocate on GC heap

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-10-24T13:16:00Z
Last change time
2014-06-12T01:37:09Z
Keywords
performance
Assigned to
nobody
Creator
verylonglogin.reg

Comments

Comment #0 by verylonglogin.reg — 2013-10-24T13:16:45Z
This has already been introduced when fixing Issue 2356 in dmd pull 1883 [1] but was reverted because of Issue 11238 in dmd pull 2682 [2]: --- void main() { int[2] m = [4, 6]; // optimized (Issue 2356) m = [m[1], m[0]]; // swap, currently calls `_d_arrayliteralTX` assert(m == [6, 4]); } --- Instead of calling `_d_arrayliteralTX` it should be rewritten to create a temporary static array if needed. [1] https://github.com/D-Programming-Language/dmd/pull/1883 [2] https://github.com/D-Programming-Language/dmd/pull/2682
Comment #1 by verylonglogin.reg — 2013-10-24T13:24:40Z
*** Issue 4881 has been marked as a duplicate of this issue. ***
Comment #2 by k.hara.pg — 2014-06-12T01:37:09Z
In 2.066 git-head, the allocation is properly removed. Introduced by: https://github.com/D-Programming-Language/dmd/pull/3467