Stop turning transmutes into discriminants in mir-opt
Partially reverts 109612, as after 109993 these aren't actually equivalent any more, and I'm no longer confident this was ever an improvement in the first place.
This commit is contained in:
parent
8e8116cfe5
commit
363c202581
3 changed files with 49 additions and 152 deletions
|
@ -5,7 +5,6 @@ use crate::MirPass;
|
|||
use rustc_hir::Mutability;
|
||||
use rustc_middle::mir::*;
|
||||
use rustc_middle::ty::layout::ValidityRequirement;
|
||||
use rustc_middle::ty::util::IntTypeExt;
|
||||
use rustc_middle::ty::{self, ParamEnv, SubstsRef, Ty, TyCtxt};
|
||||
use rustc_span::symbol::Symbol;
|
||||
use rustc_target::abi::FieldIdx;
|
||||
|
@ -163,18 +162,6 @@ impl<'tcx> InstSimplifyContext<'tcx, '_> {
|
|||
return;
|
||||
}
|
||||
|
||||
// Transmuting a fieldless enum to its repr is a discriminant read
|
||||
if let ty::Adt(adt_def, ..) = operand_ty.kind()
|
||||
&& adt_def.is_enum()
|
||||
&& adt_def.is_payloadfree()
|
||||
&& let Some(place) = operand.place()
|
||||
&& let Some(repr_int) = adt_def.repr().int
|
||||
&& repr_int.to_ty(self.tcx) == *cast_ty
|
||||
{
|
||||
*rvalue = Rvalue::Discriminant(place);
|
||||
return;
|
||||
}
|
||||
|
||||
// Transmuting a transparent struct/union to a field's type is a projection
|
||||
if let ty::Adt(adt_def, substs) = operand_ty.kind()
|
||||
&& adt_def.repr().transparent()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue