Description
Background discussion: #71911 (comment)
If we have an assignment of Rvalue::Aggregate
in const-prop, and we can figure out that all fields are Operand::Const
, we end up replacing the Rvalue::Aggregate
with an Rvalue::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 a None
where the Some
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 and ScalarPair
s? Other opinions?