Skip to content

dead-code optimize if const { expr } even in opt-level=0 #85836

Closed
@scottmcm

Description

@scottmcm

inline_const tracking issue: #76001

Inspired by @oli-obk's comment in #85828 (comment)

For things like if const { expr } { 0 } else { do something complex } it'd be nice to not have to even give LLVM the code for the else branch to have to emit. Ought to save time and binary size.

Tentatively marked mir-opt, since we presumably still need to make the MIR for it, in order to borrow-check and such the unreachable code. But might need to be codegen-time instead to pick up on monomorphized inline constants.

Hopefully should be doable relatively easily when the const is an inline const, since that forces const folding already, and thus there should just be a const true in the MIR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    C-enhancementCategory: An issue proposing an enhancement or a PR with one.F-inline_constInline constants (aka: const blocks, const expressions, anonymous constants)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions