-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
Const prop creates assignments from large constants #73203
Copy link
Copy link
Closed
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.C-optimizationCategory: An issue highlighting optimization opportunities or PRs implementing suchCategory: An issue highlighting optimization opportunities or PRs implementing suchT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
Background discussion: #71911 (comment)
If we have an assignment of
Rvalue::Aggregatein const-prop, and we can figure out that all fields areOperand::Const, we end up replacing theRvalue::Aggregatewith anRvalue::Useof a constant that contains the entire aggregate. This may end up creating large assignments that copy from constant memory to the stack at runtime. It may sometimes be cheaper to just build the constant at runtime. This is very true if the constant is actually aNonewhere theSomepart is a huge value. We'd have a very big constant with most bits undefined that we copy over, even if the runtime operation would just be "set the discriminant bits".cc @rust-lang/wg-mir-opt
Should we have some heuristic here? Should we only do this optimization for
Scalars andScalarPairs? Other opinions?