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

Store the dest collection as span to a temp for CopyTo optimization #71270

Open
RikkiGibson opened this issue Dec 14, 2023 · 1 comment
Open
Labels
Area-Compilers Code Gen Quality Room for improvement in the quality of the compiler's generated code New Feature - Collection Expressions
Milestone

Comments

@RikkiGibson
Copy link
Contributor

We removed the span temp for now per #71195 (comment).

We'd like to reintroduce the span temp later, perhaps only when non-async, or when lowering can prove that the span will not be used across an await boundary, or perhaps even reinitializing the span temp when it is used across an await boundary.

This would result in a maybe 2% perf improvement for CopyTo codegen.

T[] result = [..arr1, ..arr2];

// currently becomes
((Span<T>)arr1).CopyTo((Span<T>)result).Slice(...));
((Span<T>)arr2).CopyTo((Span<T>)result).Slice(...));

// we could instead do:
Span<T> spanTemp = result;
((Span<T>)arr1).CopyTo(spanTemp.Slice(...));
((Span<T>)arr2).CopyTo(spanTemp.Slice(...));
@dotnet-issue-labeler dotnet-issue-labeler bot added Area-Compilers untriaged Issues and PRs which have not yet been triaged by a lead labels Dec 14, 2023
@RikkiGibson RikkiGibson added Code Gen Quality Room for improvement in the quality of the compiler's generated code New Feature - Collection Expressions labels Dec 14, 2023
@CyrusNajmabadi
Copy link
Member

Yes. This seems reasonable to do. Not hugely important. But why not have better code gen and better perf?

@jaredpar jaredpar added this to the Backlog milestone Jan 2, 2024
@jaredpar jaredpar removed the untriaged Issues and PRs which have not yet been triaged by a lead label Jan 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers Code Gen Quality Room for improvement in the quality of the compiler's generated code New Feature - Collection Expressions
Projects
None yet
Development

No branches or pull requests

3 participants