Skip to content

Redundant field read in Vec::clear() #51802

Closed
@lnicola

Description

@lnicola

See https://play.rust-lang.org/?gist=2754f11f7236754b2121eb9e4c12aa73&version=nightly&mode=release. The length of the Vec is read before being written to.

I would have expected the peephole optimizer in LLVM to recognize that pattern. Interestingly, it's not a regression; according to https://rust.godbolt.org/, the issue was even present in rustc 1.0.

Metadata

Metadata

Assignees

No one assigned

    Labels

    A-LLVMArea: Code generation parts specific to LLVM. Both correctness bugs and optimization-related issues.C-enhancementCategory: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.WG-llvmWorking group: LLVM backend code generation

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions