Bug 10085 – Inefficient codegen for initialisation and variadic arguments

Status
NEW
Severity
normal
Priority
P3
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-05-14T23:10:31Z
Last change time
2024-12-13T18:06:53Z
Assigned to
No Owner
Creator
Diggory
Moved to GitHub: dmd#18581 →

Comments

Comment #0 by diggsey — 2013-05-14T23:10:31Z
Given code such as the following: struct Vector3i { int[3] array; this(int[3] array...) { this.array = array; } } void main() { auto vec = Vector3i(1, 2, 3); } When compiled with optimisation and inlining turned on, the generated code will write to the fixed size array 5 times in the process of initialisation: 1) Write zeros to "vec.array" 2) Write zeros to temporary argument array 3) Write 1, 2, 3 to temporary variables 4) Copy temporary variables into temporary argument array 5) Call "memcpy" to copy temporary argument array to "vec.array" Clearly this could be done by simply writing 1, 2, 3 to "vec.array". It seems like any optimisations on these sort of operations would speed up a lot of code...
Comment #1 by bearophile_hugs — 2013-05-15T03:22:50Z
See also Issue 5212
Comment #2 by robert.schadek — 2024-12-13T18:06:53Z
THIS ISSUE HAS BEEN MOVED TO GITHUB https://github.com/dlang/dmd/issues/18581 DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB