Const prop creates assignments from large constants #73203
Labels
A-mir-opt
Area: MIR optimizations
C-enhancement
Category: An issue proposing an enhancement or a PR with one.
C-optimization
Category: An issue highlighting optimization opportunities or PRs implementing such
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Background discussion: #71911 (comment)
If we have an assignment of
Rvalue::Aggregate
in const-prop, and we can figure out that all fields areOperand::Const
, we end up replacing theRvalue::Aggregate
with anRvalue::Use
of 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 aNone
where theSome
part 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
Scalar
s andScalarPair
s? Other opinions?The text was updated successfully, but these errors were encountered: