Skip to content

Commit 3abc321

Browse files
committed
gnv: Merge array and scalar branch together
1 parent 604a338 commit 3abc321

File tree

1 file changed

+4
-13
lines changed
  • compiler/rustc_mir_transform/src

1 file changed

+4
-13
lines changed

compiler/rustc_mir_transform/src/gvn.rs

+4-13
Original file line numberDiff line numberDiff line change
@@ -416,16 +416,9 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
416416
};
417417
let ptr_imm = Immediate::new_pointer_with_meta(data, meta, &self.ecx);
418418
ImmTy::from_immediate(ptr_imm, ty).into()
419-
} else if matches!(kind, AggregateTy::Array) {
420-
let dest = self.ecx.allocate(ty, MemoryKind::Stack).ok()?;
421-
// FIXME: Can we speed it up by using `ecx.write_immediate(.ScalarPair(_), dest)`?
422-
for (field_index, op) in fields.iter().copied().enumerate() {
423-
let field_dest = self.ecx.project_field(&dest, field_index).ok()?;
424-
self.ecx.copy_op(op, &field_dest).ok()?;
425-
}
426-
let dest = dest.map_provenance(|prov| prov.as_immutable());
427-
dest.into()
428-
} else if matches!(ty.abi, Abi::Scalar(..) | Abi::ScalarPair(..)) {
419+
} else if matches!(kind, AggregateTy::Array)
420+
|| matches!(ty.abi, Abi::Scalar(..) | Abi::ScalarPair(..))
421+
{
429422
let dest = self.ecx.allocate(ty, MemoryKind::Stack).ok()?;
430423
let variant_dest = if let Some(variant) = variant {
431424
self.ecx.project_downcast(&dest, variant).ok()?
@@ -437,9 +430,7 @@ impl<'body, 'tcx> VnState<'body, 'tcx> {
437430
self.ecx.copy_op(op, &field_dest).ok()?;
438431
}
439432
self.ecx.write_discriminant(variant.unwrap_or(FIRST_VARIANT), &dest).ok()?;
440-
self.ecx
441-
.alloc_mark_immutable(dest.ptr().provenance.unwrap().alloc_id())
442-
.ok()?;
433+
let dest = dest.map_provenance(|prov| prov.as_immutable());
443434
dest.into()
444435
} else {
445436
return None;

0 commit comments

Comments
 (0)