www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 10085] New: Inefficient codegen for initialisation and variadic arguments

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10085

           Summary: Inefficient codegen for initialisation and variadic
                    arguments
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: diggsey googlemail.com


--- Comment #0 from Diggory <diggsey googlemail.com> 2013-05-14 23:10:31 PDT ---
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...

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 14 2013
parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=10085


bearophile_hugs eml.cc changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bearophile_hugs eml.cc


--- Comment #1 from bearophile_hugs eml.cc 2013-05-15 03:22:50 PDT ---
See also Issue 5212

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
May 15 2013