Skip to content

Creating a nested MaybeUninit array unnecessarily calls memset #139355

Description

@abgros

This function calls memset:

fn create_uninit_array() -> [[MaybeUninit<u8>; 4]; 200] {
    [[MaybeUninit::<u8>::uninit(); 4]; 200]
}

and this one doesn't:

fn create_uninit_array_fast() -> [MaybeUninit<u8>; 800] {
    [MaybeUninit::<u8>::uninit(); 800]
}

I would have expected the same assembly to be generated for both cases.

See on Godbolt

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchI-slowIssue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions