Skip to content

Small arrays of MaybeUninit::<u8>::uninit() are deoptimized to all zeroes #145121

@saethlin

Description

@saethlin

I started by looking at rust-lang/rust#139355 but it looks like the root cause can be produce with much less Rust code: https://godbolt.org/z/4Kv5Gbdse

As far as I can tell, things go wrong twice. SROA tries to splat the undef i8, but it generates a generic sequence of instructions in the process instead of just an undef of the target type. Then EarlyCSE sees the splat and replaces it with a 0.

I have a candidate fix for this, though I'm a bit of a novice at working on LLVM.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions