July 31, 2011 [Issue 6421] New: Fixed size array literal assignment optimization | ||||
---|---|---|---|---|
| ||||
http://d.puremagic.com/issues/show_bug.cgi?id=6421 Summary: Fixed size array literal assignment optimization Product: D Version: D2 Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: DMD AssignedTo: nobody@puremagic.com ReportedBy: bearophile_hugs@eml.cc --- Comment #0 from bearophile_hugs@eml.cc 2011-07-31 16:56:49 PDT --- From a comment by Peter Alexander: > int[3] a = [1, 2, 3]; // in D, this allocates then copies int a[3] = {1, 2, 3}; // in C++, this doesn't allocate > > Apparently, to avoid the allocation in D, you must do: > > static const int[3] staticA = [1, 2, 3]; // in data segment int[3] a = staticA; // non-allocating copy > > These little 'behind your back' allocations are good examples of my previous two points. Memory allocations caused by this, inside an inner loop, have given me performance troubles. I suggest to add an optimization to the DMD front-end to avoid this problem. Some comments received: Don: > Yeah, it's not fundamental, and not even very complicated. The current implementation was a quick hack to provide the functionality, that hasn't been replaced with a proper implementation yet. All that's required to fix it is a bit of code in e2ir.c. Peter Alexander: > Also, I think it > would be worth while adding it to the language definition so that it's > not merely an implementation detail. Timon Gehr: > I think it should be more than an implementation detail, as it can severely affect performance. How do you specify this in the D language definition? What are the corner cases? -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
August 01, 2011 [Issue 6421] Fixed size array literal assignment optimization | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile_hugs@eml.cc | http://d.puremagic.com/issues/show_bug.cgi?id=6421 --- Comment #1 from bearophile_hugs@eml.cc 2011-08-01 06:36:11 PDT --- This bug is related to bug 2356, the difference is this enhancement request asks for a language definition change too. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- |
Copyright © 1999-2021 by the D Language Foundation