Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile-time array literal repeatedly allocated at run-time despite not being used #762

Closed
kiith-sa opened this issue Oct 25, 2014 · 1 comment · Fixed by #763
Closed

Comments

@kiith-sa
Copy link

Test case:

void main(string[] args)
{
    foreach(i; 0 .. 10000)
    {
        enum sortedIDs = [2, 4, 1, 5, 7];
    }
}

When compiled with LDC (both unoptimized and -O3 -release), this calls _d_newarrayU 10000 times. With DMD, _d_newarrayU is never called. This leads to extremely low performance when using compile-time arrays in code generation for in tight loops.

@kiith-sa
Copy link
Author

note: the foreach loop is not needed to reproduce the issue; it's just there to check that _d_newarrayU is in fact called in every iteration.

dnadlinger added a commit to dnadlinger/ldc that referenced this issue Oct 25, 2014
dnadlinger added a commit to dnadlinger/ldc that referenced this issue Oct 25, 2014
dnadlinger added a commit to dnadlinger/ldc that referenced this issue Oct 25, 2014
dnadlinger added a commit to ldc-developers/dmd-testsuite that referenced this issue Nov 6, 2014
dnadlinger added a commit to dnadlinger/ldc that referenced this issue Nov 6, 2014
kinke pushed a commit to kinke/ldc that referenced this issue Nov 9, 2014
dnadlinger added a commit that referenced this issue Nov 10, 2014
Add test case for GitHub issue #762.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant