Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit ac4f464

Browse files
committed
prevent code bloat for for arrays
1 parent 6de604b commit ac4f464

File tree

1 file changed

+8
-0
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+8
-0
lines changed

compiler/rustc_mir_transform/src/gvn.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1488,6 +1488,14 @@ impl<'tcx> VnState<'_, 'tcx> {
14881488
if let Value::Constant { value, disambiguator: _ } = value
14891489
&& value.is_deterministic()
14901490
{
1491+
// Prevent code bloat that makes
1492+
// `_2 = _1` now resolved to `_2 = <evaluated array>`.
1493+
if let Const::Val(_, ty) = value
1494+
&& ty.is_array()
1495+
&& self.rev_locals[index].len() > 1
1496+
{
1497+
return None;
1498+
}
14911499
return Some(ConstOperand { span: DUMMY_SP, user_ty: None, const_: *value });
14921500
}
14931501

0 commit comments

Comments
 (0)