-
-
Notifications
You must be signed in to change notification settings - Fork 15.9k
dead-code optimize if const { expr } even in opt-level=0 #85836
Copy link
Copy link
Closed
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.F-inline_constInline constants (aka: const blocks, const expressions, anonymous constants)Inline constants (aka: const blocks, const expressions, anonymous constants)
Description
Activity
Metadata
Metadata
Assignees
Labels
C-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.F-inline_constInline constants (aka: const blocks, const expressions, anonymous constants)Inline constants (aka: const blocks, const expressions, anonymous constants)
inline_consttracking issue: #76001Inspired 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 truein the MIR.