diff --git a/compiler/rustc_mir_transform/src/const_prop.rs b/compiler/rustc_mir_transform/src/const_prop.rs index e66d5e0a9f9..c5824c30770 100644 --- a/compiler/rustc_mir_transform/src/const_prop.rs +++ b/compiler/rustc_mir_transform/src/const_prop.rs @@ -1,29 +1,22 @@ //! Propagates constants for early reporting of statically known //! assertion failures -use either::Right; -use rustc_const_eval::ReportErrorExt; -use rustc_data_structures::fx::FxHashSet; -use rustc_hir::def::DefKind; -use rustc_index::bit_set::BitSet; -use rustc_index::{IndexSlice, IndexVec}; -use rustc_middle::mir::visit::{ - MutVisitor, MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor, +use rustc_const_eval::interpret::{ + self, compile_time_machine, AllocId, ConstAllocation, FnArg, Frame, ImmTy, InterpCx, + InterpResult, OpTy, PlaceTy, Pointer, }; +use rustc_data_structures::fx::FxHashSet; +use rustc_index::bit_set::BitSet; +use rustc_index::IndexVec; +use rustc_middle::mir::visit::{MutatingUseContext, NonMutatingUseContext, PlaceContext, Visitor}; use rustc_middle::mir::*; use rustc_middle::query::TyCtxtAt; -use rustc_middle::ty::layout::{LayoutError, LayoutOf, LayoutOfHelpers, TyAndLayout}; -use rustc_middle::ty::{self, GenericArgs, Instance, ParamEnv, Ty, TyCtxt, TypeVisitableExt}; -use rustc_span::{def_id::DefId, Span}; -use rustc_target::abi::{self, HasDataLayout, Size, TargetDataLayout}; +use rustc_middle::ty::layout::TyAndLayout; +use rustc_middle::ty::{self, ParamEnv, TyCtxt}; +use rustc_span::def_id::DefId; +use rustc_target::abi::Size; use rustc_target::spec::abi::Abi as CallAbi; -use crate::dataflow_const_prop::Patch; -use rustc_const_eval::interpret::{ - self, compile_time_machine, AllocId, ConstAllocation, FnArg, Frame, ImmTy, Immediate, InterpCx, - InterpResult, MemoryKind, OpTy, PlaceTy, Pointer, Scalar, StackPopCleanup, -}; - /// The maximum number of bytes that we'll allocate space for a local or the return value. /// Needed for #66397, because otherwise we eval into large places and that can cause OOM or just /// Severely regress performance. @@ -56,62 +49,7 @@ pub(crate) macro throw_machine_stop_str($($tt:tt)*) {{ throw_machine_stop!(Zst) }} -pub struct ConstProp; - -impl<'tcx> MirPass<'tcx> for ConstProp { - fn is_enabled(&self, sess: &rustc_session::Session) -> bool { - sess.mir_opt_level() >= 2 - } - - #[instrument(skip(self, tcx), level = "debug")] - fn run_pass(&self, tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { - // will be evaluated by miri and produce its errors there - if body.source.promoted.is_some() { - return; - } - - let def_id = body.source.def_id().expect_local(); - let def_kind = tcx.def_kind(def_id); - let is_fn_like = def_kind.is_fn_like(); - let is_assoc_const = def_kind == DefKind::AssocConst; - - // Only run const prop on functions, methods, closures and associated constants - if !is_fn_like && !is_assoc_const { - // skip anon_const/statics/consts because they'll be evaluated by miri anyway - trace!("ConstProp skipped for {:?}", def_id); - return; - } - - // FIXME(welseywiser) const prop doesn't work on coroutines because of query cycles - // computing their layout. - if tcx.is_coroutine(def_id.to_def_id()) { - trace!("ConstProp skipped for coroutine {:?}", def_id); - return; - } - - trace!("ConstProp starting for {:?}", def_id); - - // FIXME(oli-obk, eddyb) Optimize locals (or even local paths) to hold - // constants, instead of just checking for const-folding succeeding. - // That would require a uniform one-def no-mutation analysis - // and RPO (or recursing when needing the value of a local). - let mut optimization_finder = ConstPropagator::new(body, tcx); - - // Traverse the body in reverse post-order, to ensure that `FullConstProp` locals are - // assigned before being read. - for &bb in body.basic_blocks.reverse_postorder() { - let data = &body.basic_blocks[bb]; - optimization_finder.visit_basic_block_data(bb, data); - } - - let mut patch = optimization_finder.patch; - patch.visit_body_preserves_cfg(body); - - trace!("ConstProp done for {:?}", def_id); - } -} - -pub struct ConstPropMachine<'mir, 'tcx> { +pub(crate) struct ConstPropMachine<'mir, 'tcx> { /// The virtual call stack. stack: Vec>, pub written_only_inside_own_block_locals: FxHashSet, @@ -267,297 +205,6 @@ impl<'mir, 'tcx> interpret::Machine<'mir, 'tcx> for ConstPropMachine<'mir, 'tcx> } } -/// Finds optimization opportunities on the MIR. -struct ConstPropagator<'mir, 'tcx> { - ecx: InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>, - tcx: TyCtxt<'tcx>, - param_env: ParamEnv<'tcx>, - local_decls: &'mir IndexSlice>, - patch: Patch<'tcx>, -} - -impl<'tcx> LayoutOfHelpers<'tcx> for ConstPropagator<'_, 'tcx> { - type LayoutOfResult = Result, LayoutError<'tcx>>; - - #[inline] - fn handle_layout_err(&self, err: LayoutError<'tcx>, _: Span, _: Ty<'tcx>) -> LayoutError<'tcx> { - err - } -} - -impl HasDataLayout for ConstPropagator<'_, '_> { - #[inline] - fn data_layout(&self) -> &TargetDataLayout { - &self.tcx.data_layout - } -} - -impl<'tcx> ty::layout::HasTyCtxt<'tcx> for ConstPropagator<'_, 'tcx> { - #[inline] - fn tcx(&self) -> TyCtxt<'tcx> { - self.tcx - } -} - -impl<'tcx> ty::layout::HasParamEnv<'tcx> for ConstPropagator<'_, 'tcx> { - #[inline] - fn param_env(&self) -> ty::ParamEnv<'tcx> { - self.param_env - } -} - -impl<'mir, 'tcx> ConstPropagator<'mir, 'tcx> { - fn new(body: &'mir Body<'tcx>, tcx: TyCtxt<'tcx>) -> ConstPropagator<'mir, 'tcx> { - let def_id = body.source.def_id(); - let args = &GenericArgs::identity_for_item(tcx, def_id); - let param_env = tcx.param_env_reveal_all_normalized(def_id); - - let can_const_prop = CanConstProp::check(tcx, param_env, body); - let mut ecx = InterpCx::new( - tcx, - tcx.def_span(def_id), - param_env, - ConstPropMachine::new(can_const_prop), - ); - - let ret_layout = ecx - .layout_of(body.bound_return_ty().instantiate(tcx, args)) - .ok() - // Don't bother allocating memory for large values. - // I don't know how return types can seem to be unsized but this happens in the - // `type/type-unsatisfiable.rs` test. - .filter(|ret_layout| { - ret_layout.is_sized() && ret_layout.size < Size::from_bytes(MAX_ALLOC_LIMIT) - }) - .unwrap_or_else(|| ecx.layout_of(tcx.types.unit).unwrap()); - - let ret = ecx - .allocate(ret_layout, MemoryKind::Stack) - .expect("couldn't perform small allocation") - .into(); - - ecx.push_stack_frame( - Instance::new(def_id, args), - body, - &ret, - StackPopCleanup::Root { cleanup: false }, - ) - .expect("failed to push initial stack frame"); - - for local in body.local_decls.indices() { - // Mark everything initially live. - // This is somewhat dicey since some of them might be unsized and it is incoherent to - // mark those as live... We rely on `local_to_place`/`local_to_op` in the interpreter - // stopping us before those unsized immediates can cause issues deeper in the - // interpreter. - ecx.frame_mut().locals[local].make_live_uninit(); - } - - let patch = Patch::new(tcx); - ConstPropagator { ecx, tcx, param_env, local_decls: &body.local_decls, patch } - } - - fn get_const(&self, place: Place<'tcx>) -> Option> { - let op = match self.ecx.eval_place_to_op(place, None) { - Ok(op) => { - if op - .as_mplace_or_imm() - .right() - .is_some_and(|imm| matches!(*imm, Immediate::Uninit)) - { - // Make sure nobody accidentally uses this value. - return None; - } - op - } - Err(e) => { - trace!("get_const failed: {:?}", e.into_kind().debug()); - return None; - } - }; - - // Try to read the local as an immediate so that if it is representable as a scalar, we can - // handle it as such, but otherwise, just return the value as is. - Some(match self.ecx.read_immediate_raw(&op) { - Ok(Right(imm)) => imm.into(), - _ => op, - }) - } - - /// Remove `local` from the pool of `Locals`. Allows writing to them, - /// but not reading from them anymore. - fn remove_const(ecx: &mut InterpCx<'mir, 'tcx, ConstPropMachine<'mir, 'tcx>>, local: Local) { - ecx.frame_mut().locals[local].make_live_uninit(); - ecx.machine.written_only_inside_own_block_locals.remove(&local); - } - - fn check_rvalue(&mut self, rvalue: &Rvalue<'tcx>) -> Option<()> { - // Perform any special handling for specific Rvalue types. - // Generally, checks here fall into one of two categories: - // 1. Additional checking to provide useful lints to the user - // - In this case, we will do some validation and then fall through to the - // end of the function which evals the assignment. - // 2. Working around bugs in other parts of the compiler - // - In this case, we'll return `None` from this function to stop evaluation. - match rvalue { - // Do not try creating references (#67862) - Rvalue::AddressOf(_, place) | Rvalue::Ref(_, _, place) => { - trace!("skipping AddressOf | Ref for {:?}", place); - - // This may be creating mutable references or immutable references to cells. - // If that happens, the pointed to value could be mutated via that reference. - // Since we aren't tracking references, the const propagator loses track of what - // value the local has right now. - // Thus, all locals that have their reference taken - // must not take part in propagation. - Self::remove_const(&mut self.ecx, place.local); - - return None; - } - Rvalue::ThreadLocalRef(def_id) => { - trace!("skipping ThreadLocalRef({:?})", def_id); - - return None; - } - // There's no other checking to do at this time. - Rvalue::Aggregate(..) - | Rvalue::Use(..) - | Rvalue::CopyForDeref(..) - | Rvalue::Repeat(..) - | Rvalue::Len(..) - | Rvalue::Cast(..) - | Rvalue::ShallowInitBox(..) - | Rvalue::Discriminant(..) - | Rvalue::NullaryOp(..) - | Rvalue::UnaryOp(..) - | Rvalue::BinaryOp(..) - | Rvalue::CheckedBinaryOp(..) => {} - } - - // FIXME we need to revisit this for #67176 - if rvalue.has_param() { - trace!("skipping, has param"); - return None; - } - if !rvalue - .ty(&self.ecx.frame().body.local_decls, *self.ecx.tcx) - .is_sized(*self.ecx.tcx, self.param_env) - { - // the interpreter doesn't support unsized locals (only unsized arguments), - // but rustc does (in a kinda broken way), so we have to skip them here - return None; - } - - Some(()) - } - - // Attempt to use algebraic identities to eliminate constant expressions - fn eval_rvalue_with_identities( - &mut self, - rvalue: &Rvalue<'tcx>, - place: Place<'tcx>, - ) -> Option<()> { - match rvalue { - Rvalue::BinaryOp(op, box (left, right)) - | Rvalue::CheckedBinaryOp(op, box (left, right)) => { - let l = self.ecx.eval_operand(left, None).and_then(|x| self.ecx.read_immediate(&x)); - let r = - self.ecx.eval_operand(right, None).and_then(|x| self.ecx.read_immediate(&x)); - - let const_arg = match (l, r) { - (Ok(x), Err(_)) | (Err(_), Ok(x)) => x, // exactly one side is known - (Err(_), Err(_)) => return None, // neither side is known - (Ok(_), Ok(_)) => return self.ecx.eval_rvalue_into_place(rvalue, place).ok(), // both sides are known - }; - - if !matches!(const_arg.layout.abi, abi::Abi::Scalar(..)) { - // We cannot handle Scalar Pair stuff. - // No point in calling `eval_rvalue_into_place`, since only one side is known - return None; - } - - let arg_value = const_arg.to_scalar().to_bits(const_arg.layout.size).ok()?; - let dest = self.ecx.eval_place(place).ok()?; - - match op { - BinOp::BitAnd if arg_value == 0 => { - self.ecx.write_immediate(*const_arg, &dest).ok() - } - BinOp::BitOr - if arg_value == const_arg.layout.size.truncate(u128::MAX) - || (const_arg.layout.ty.is_bool() && arg_value == 1) => - { - self.ecx.write_immediate(*const_arg, &dest).ok() - } - BinOp::Mul if const_arg.layout.ty.is_integral() && arg_value == 0 => { - if let Rvalue::CheckedBinaryOp(_, _) = rvalue { - let val = Immediate::ScalarPair( - const_arg.to_scalar(), - Scalar::from_bool(false), - ); - self.ecx.write_immediate(val, &dest).ok() - } else { - self.ecx.write_immediate(*const_arg, &dest).ok() - } - } - _ => None, - } - } - _ => self.ecx.eval_rvalue_into_place(rvalue, place).ok(), - } - } - - fn replace_with_const(&mut self, place: Place<'tcx>) -> Option> { - // This will return None if the above `const_prop` invocation only "wrote" a - // type whose creation requires no write. E.g. a coroutine whose initial state - // consists solely of uninitialized memory (so it doesn't capture any locals). - let value = self.get_const(place)?; - if !self.tcx.consider_optimizing(|| format!("ConstantPropagation - {value:?}")) { - return None; - } - trace!("replacing {:?} with {:?}", place, value); - - // FIXME: figure out what to do when read_immediate_raw fails - let imm = self.ecx.read_immediate_raw(&value).ok()?; - - let Right(imm) = imm else { return None }; - match *imm { - Immediate::Scalar(scalar) if scalar.try_to_int().is_ok() => { - Some(Const::from_scalar(self.tcx, scalar, value.layout.ty)) - } - Immediate::ScalarPair(l, r) if l.try_to_int().is_ok() && r.try_to_int().is_ok() => { - let alloc_id = self - .ecx - .intern_with_temp_alloc(value.layout, |ecx, dest| { - ecx.write_immediate(*imm, dest) - }) - .ok()?; - - Some(Const::Val( - ConstValue::Indirect { alloc_id, offset: Size::ZERO }, - value.layout.ty, - )) - } - // Scalars or scalar pairs that contain undef values are assumed to not have - // successfully evaluated and are thus not propagated. - _ => None, - } - } - - fn ensure_not_propagated(&self, local: Local) { - if cfg!(debug_assertions) { - assert!( - self.get_const(local.into()).is_none() - || self - .layout_of(self.local_decls[local].ty) - .map_or(true, |layout| layout.is_zst()), - "failed to remove values for `{local:?}`, value={:?}", - self.get_const(local.into()), - ) - } - } -} - /// The mode that `ConstProp` is allowed to run in for a given `Local`. #[derive(Clone, Copy, Debug, PartialEq)] pub enum ConstPropMode { @@ -677,154 +324,3 @@ impl<'tcx> Visitor<'tcx> for CanConstProp { } } } - -impl<'tcx> Visitor<'tcx> for ConstPropagator<'_, 'tcx> { - fn visit_operand(&mut self, operand: &Operand<'tcx>, location: Location) { - self.super_operand(operand, location); - if let Some(place) = operand.place() - && let Some(value) = self.replace_with_const(place) - { - self.patch.before_effect.insert((location, place), value); - } - } - - fn visit_projection_elem( - &mut self, - _: PlaceRef<'tcx>, - elem: PlaceElem<'tcx>, - _: PlaceContext, - location: Location, - ) { - if let PlaceElem::Index(local) = elem - && let Some(value) = self.replace_with_const(local.into()) - { - self.patch.before_effect.insert((location, local.into()), value); - } - } - - fn visit_assign(&mut self, place: &Place<'tcx>, rvalue: &Rvalue<'tcx>, location: Location) { - self.super_assign(place, rvalue, location); - - let Some(()) = self.check_rvalue(rvalue) else { - trace!("rvalue check failed, removing const"); - Self::remove_const(&mut self.ecx, place.local); - return; - }; - - match self.ecx.machine.can_const_prop[place.local] { - // Do nothing if the place is indirect. - _ if place.is_indirect() => {} - ConstPropMode::NoPropagation => self.ensure_not_propagated(place.local), - ConstPropMode::OnlyInsideOwnBlock | ConstPropMode::FullConstProp => { - if let Some(()) = self.eval_rvalue_with_identities(rvalue, *place) { - // If this was already an evaluated constant, keep it. - if let Rvalue::Use(Operand::Constant(c)) = rvalue - && let Const::Val(..) = c.const_ - { - trace!( - "skipping replace of Rvalue::Use({:?} because it is already a const", - c - ); - } else if let Some(operand) = self.replace_with_const(*place) { - self.patch.assignments.insert(location, operand); - } - } else { - // Const prop failed, so erase the destination, ensuring that whatever happens - // from here on, does not know about the previous value. - // This is important in case we have - // ```rust - // let mut x = 42; - // x = SOME_MUTABLE_STATIC; - // // x must now be uninit - // ``` - // FIXME: we overzealously erase the entire local, because that's easier to - // implement. - trace!( - "propagation into {:?} failed. - Nuking the entire site from orbit, it's the only way to be sure", - place, - ); - Self::remove_const(&mut self.ecx, place.local); - } - } - } - } - - fn visit_statement(&mut self, statement: &Statement<'tcx>, location: Location) { - trace!("visit_statement: {:?}", statement); - - // We want to evaluate operands before any change to the assigned-to value, - // so we recurse first. - self.super_statement(statement, location); - - match statement.kind { - StatementKind::SetDiscriminant { ref place, .. } => { - match self.ecx.machine.can_const_prop[place.local] { - // Do nothing if the place is indirect. - _ if place.is_indirect() => {} - ConstPropMode::NoPropagation => self.ensure_not_propagated(place.local), - ConstPropMode::FullConstProp | ConstPropMode::OnlyInsideOwnBlock => { - if self.ecx.statement(statement).is_ok() { - trace!("propped discriminant into {:?}", place); - } else { - Self::remove_const(&mut self.ecx, place.local); - } - } - } - } - StatementKind::StorageLive(local) => { - Self::remove_const(&mut self.ecx, local); - } - // We do not need to mark dead locals as such. For `FullConstProp` locals, - // this allows to propagate the single assigned value in this case: - // ``` - // let x = SOME_CONST; - // if a { - // f(copy x); - // StorageDead(x); - // } else { - // g(copy x); - // StorageDead(x); - // } - // ``` - // - // This may propagate a constant where the local would be uninit or dead. - // In both cases, this does not matter, as those reads would be UB anyway. - _ => {} - } - } - - fn visit_basic_block_data(&mut self, block: BasicBlock, data: &BasicBlockData<'tcx>) { - self.super_basic_block_data(block, data); - - // We remove all Locals which are restricted in propagation to their containing blocks and - // which were modified in the current block. - // Take it out of the ecx so we can get a mutable reference to the ecx for `remove_const`. - let mut written_only_inside_own_block_locals = - std::mem::take(&mut self.ecx.machine.written_only_inside_own_block_locals); - - // This loop can get very hot for some bodies: it check each local in each bb. - // To avoid this quadratic behaviour, we only clear the locals that were modified inside - // the current block. - for local in written_only_inside_own_block_locals.drain() { - debug_assert_eq!( - self.ecx.machine.can_const_prop[local], - ConstPropMode::OnlyInsideOwnBlock - ); - Self::remove_const(&mut self.ecx, local); - } - self.ecx.machine.written_only_inside_own_block_locals = - written_only_inside_own_block_locals; - - if cfg!(debug_assertions) { - for (local, &mode) in self.ecx.machine.can_const_prop.iter_enumerated() { - match mode { - ConstPropMode::FullConstProp => {} - ConstPropMode::NoPropagation | ConstPropMode::OnlyInsideOwnBlock => { - self.ensure_not_propagated(local); - } - } - } - } - } -} diff --git a/compiler/rustc_mir_transform/src/lib.rs b/compiler/rustc_mir_transform/src/lib.rs index 10ebf469d85..7da18b647d1 100644 --- a/compiler/rustc_mir_transform/src/lib.rs +++ b/compiler/rustc_mir_transform/src/lib.rs @@ -590,7 +590,6 @@ fn run_optimization_passes<'tcx>(tcx: TyCtxt<'tcx>, body: &mut Body<'tcx>) { &separate_const_switch::SeparateConstSwitch, &gvn::GVN, &simplify::SimplifyLocals::AfterGVN, - &const_prop::ConstProp, &dataflow_const_prop::DataflowConstProp, &const_debuginfo::ConstDebugInfo, &o1(simplify_branches::SimplifyConstCondition::AfterConstProp), diff --git a/tests/codegen/inherit_overflow.rs b/tests/codegen/inherit_overflow.rs index 39909d7abfd..fa9ee0ae12a 100644 --- a/tests/codegen/inherit_overflow.rs +++ b/tests/codegen/inherit_overflow.rs @@ -1,4 +1,4 @@ -// compile-flags: -Zmir-enable-passes=+Inline,+ConstProp --crate-type lib +// compile-flags: -Zmir-enable-passes=+Inline,+GVN --crate-type lib // revisions: ASSERT NOASSERT //[ASSERT] compile-flags: -Coverflow-checks=on //[NOASSERT] compile-flags: -Coverflow-checks=off diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation.main.GVN.after.32bit.mir similarity index 95% rename from tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir rename to tests/mir-opt/const_allocation.main.GVN.after.32bit.mir index 9cc4c7c4d76..f089c6741fe 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation.main.GVN.after.32bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after ConstProp +// MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - StorageLive(_2); + nop; _2 = const {ALLOC9: &&[(Option, &[&str])]}; _1 = (*_2); - StorageDead(_2); + nop; StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation.main.GVN.after.64bit.mir similarity index 95% rename from tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir rename to tests/mir-opt/const_allocation.main.GVN.after.64bit.mir index faa9d20f2d5..9cbbaf302be 100644 --- a/tests/mir-opt/const_allocation.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation.main.GVN.after.64bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after ConstProp +// MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - StorageLive(_2); + nop; _2 = const {ALLOC9: &&[(Option, &[&str])]}; _1 = (*_2); - StorageDead(_2); + nop; StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation.rs b/tests/mir-opt/const_allocation.rs index 577c61aeb7d..5b5fb524fdb 100644 --- a/tests/mir-opt/const_allocation.rs +++ b/tests/mir-opt/const_allocation.rs @@ -1,11 +1,11 @@ // skip-filecheck -// unit-test: ConstProp +// unit-test: GVN // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH static FOO: &[(Option, &[&str])] = &[(None, &[]), (None, &["foo", "bar"]), (Some(42), &["meh", "mop", "möp"])]; -// EMIT_MIR const_allocation.main.ConstProp.after.mir +// EMIT_MIR const_allocation.main.GVN.after.mir fn main() { FOO; } diff --git a/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir similarity index 94% rename from tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir rename to tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir index 898835b46e4..dfa2d808128 100644 --- a/tests/mir-opt/const_allocation2.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation2.main.GVN.after.32bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after ConstProp +// MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - StorageLive(_2); + nop; _2 = const {ALLOC9: &&[(Option, &[&u8])]}; _1 = (*_2); - StorageDead(_2); + nop; StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir similarity index 95% rename from tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir rename to tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir index f5352c2aebb..02b66987169 100644 --- a/tests/mir-opt/const_allocation2.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation2.main.GVN.after.64bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after ConstProp +// MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - StorageLive(_2); + nop; _2 = const {ALLOC9: &&[(Option, &[&u8])]}; _1 = (*_2); - StorageDead(_2); + nop; StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation2.rs b/tests/mir-opt/const_allocation2.rs index 0fcfaad842c..171592889d5 100644 --- a/tests/mir-opt/const_allocation2.rs +++ b/tests/mir-opt/const_allocation2.rs @@ -1,8 +1,8 @@ // skip-filecheck -// unit-test: ConstProp +// unit-test: GVN // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR const_allocation2.main.ConstProp.after.mir +// EMIT_MIR const_allocation2.main.GVN.after.mir fn main() { FOO; } diff --git a/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir b/tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir similarity index 96% rename from tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir rename to tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir index 624047f5b6f..386a55ee6fa 100644 --- a/tests/mir-opt/const_allocation3.main.ConstProp.after.32bit.mir +++ b/tests/mir-opt/const_allocation3.main.GVN.after.32bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after ConstProp +// MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - StorageLive(_2); + nop; _2 = const {ALLOC4: &&Packed}; _1 = (*_2); - StorageDead(_2); + nop; StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir b/tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir similarity index 96% rename from tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir rename to tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir index cdd4758e153..b9e98f8cd4c 100644 --- a/tests/mir-opt/const_allocation3.main.ConstProp.after.64bit.mir +++ b/tests/mir-opt/const_allocation3.main.GVN.after.64bit.mir @@ -1,4 +1,4 @@ -// MIR for `main` after ConstProp +// MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -7,10 +7,10 @@ fn main() -> () { bb0: { StorageLive(_1); - StorageLive(_2); + nop; _2 = const {ALLOC2: &&Packed}; _1 = (*_2); - StorageDead(_2); + nop; StorageDead(_1); _0 = const (); return; diff --git a/tests/mir-opt/const_allocation3.rs b/tests/mir-opt/const_allocation3.rs index b8c9f50977e..91a30f0587b 100644 --- a/tests/mir-opt/const_allocation3.rs +++ b/tests/mir-opt/const_allocation3.rs @@ -1,8 +1,8 @@ // skip-filecheck -// unit-test: ConstProp +// unit-test: GVN // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR const_allocation3.main.ConstProp.after.mir +// EMIT_MIR const_allocation3.main.GVN.after.mir fn main() { FOO; } diff --git a/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff b/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff index 87c07279552..c1529dbee13 100644 --- a/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff +++ b/tests/mir-opt/const_debuginfo.main.ConstDebugInfo.diff @@ -34,7 +34,8 @@ debug f => _10; let _11: std::option::Option; scope 7 { - debug o => _11; +- debug o => _11; ++ debug o => const Option::::Some(99_u16); let _12: Point; scope 8 { - debug p => _12; @@ -54,11 +55,11 @@ } bb0: { - StorageLive(_1); + nop; _1 = const 1_u8; - StorageLive(_2); + nop; _2 = const 2_u8; - StorageLive(_3); + nop; _3 = const 3_u8; StorageLive(_4); StorageLive(_5); @@ -79,17 +80,17 @@ StorageLive(_10); _10 = (const true, const false, const 123_u32); StorageLive(_11); - _11 = Option::::Some(const 99_u16); + _11 = const Option::::Some(99_u16); StorageLive(_12); _12 = const Point {{ x: 32_u32, y: 32_u32 }}; StorageLive(_13); - StorageLive(_14); + nop; _14 = const 32_u32; StorageLive(_15); _15 = const 32_u32; _13 = const 64_u32; StorageDead(_15); - StorageDead(_14); + nop; _0 = const (); StorageDead(_13); StorageDead(_12); @@ -97,9 +98,9 @@ StorageDead(_10); StorageDead(_9); StorageDead(_4); - StorageDead(_3); - StorageDead(_2); - StorageDead(_1); + nop; + nop; + nop; return; } } @@ -108,3 +109,7 @@ 20 00 00 00 20 00 00 00 │ ... ... } + ALLOC1 (size: 4, align: 2) { + 01 00 63 00 │ ..c. + } + diff --git a/tests/mir-opt/const_debuginfo.rs b/tests/mir-opt/const_debuginfo.rs index 0e5ac4b8bd6..db0c5dbb28f 100644 --- a/tests/mir-opt/const_debuginfo.rs +++ b/tests/mir-opt/const_debuginfo.rs @@ -1,5 +1,5 @@ // unit-test: ConstDebugInfo -// compile-flags: -C overflow-checks=no -Zmir-enable-passes=+ConstProp +// compile-flags: -C overflow-checks=no -Zmir-enable-passes=+GVN struct Point { x: u32, @@ -15,7 +15,7 @@ fn main() { // CHECK: debug sum => const 6_u8; // CHECK: debug s => const "hello, world!"; // CHECK: debug f => {{_.*}}; - // CHECK: debug o => {{_.*}}; + // CHECK: debug o => const Option::::Some(99_u16); // CHECK: debug p => const Point // CHECK: debug a => const 64_u32; let x = 1u8; diff --git a/tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff b/tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff similarity index 61% rename from tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff rename to tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff index 6b96c24d460..2285962fad1 100644 --- a/tests/mir-opt/const_prop/address_of_pair.fn0.ConstProp.diff +++ b/tests/mir-opt/const_prop/address_of_pair.fn0.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `fn0` before ConstProp -+ // MIR for `fn0` after ConstProp +- // MIR for `fn0` before GVN ++ // MIR for `fn0` after GVN fn fn0() -> bool { let mut _0: bool; @@ -23,24 +23,34 @@ bb0: { StorageLive(_2); - _2 = (const 1_i32, const false); - StorageLive(_3); +- _2 = (const 1_i32, const false); +- StorageLive(_3); ++ _2 = const (1_i32, false); ++ nop; _3 = &raw mut (_2.1: bool); - _2 = (const 1_i32, const false); +- _2 = (const 1_i32, const false); ++ _2 = const (1_i32, false); StorageLive(_4); (*_3) = const true; _4 = const (); StorageDead(_4); - StorageLive(_5); +- StorageLive(_5); ++ nop; StorageLive(_6); _6 = (_2.1: bool); _5 = Not(move _6); StorageDead(_6); _0 = _5; - StorageDead(_5); - StorageDead(_3); +- StorageDead(_5); +- StorageDead(_3); ++ nop; ++ nop; StorageDead(_2); return; } ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 01 00 00 00 00 __ __ __ │ .....░░░ } diff --git a/tests/mir-opt/const_prop/address_of_pair.rs b/tests/mir-opt/const_prop/address_of_pair.rs index 730ebe2ca63..1ab8a602823 100644 --- a/tests/mir-opt/const_prop/address_of_pair.rs +++ b/tests/mir-opt/const_prop/address_of_pair.rs @@ -1,6 +1,6 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR address_of_pair.fn0.ConstProp.diff +// EMIT_MIR address_of_pair.fn0.GVN.diff pub fn fn0() -> bool { // CHECK-LABEL: fn fn0( // CHECK: debug pair => [[pair:_.*]]; diff --git a/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-abort.diff similarity index 85% rename from tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/aggregate.foo.GVN.panic-abort.diff index 5e2db148de8..4f0f7fa8fa2 100644 --- a/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `foo` before ConstProp -+ // MIR for `foo` after ConstProp +- // MIR for `foo` before GVN ++ // MIR for `foo` after GVN fn foo(_1: u8) -> () { debug x => _1; @@ -25,7 +25,8 @@ StorageLive(_4); StorageLive(_5); _5 = _1; - _4 = (const 0_i32, move _5); +- _4 = (const 0_i32, move _5); ++ _4 = (const 0_i32, _1); StorageDead(_5); - _3 = (_4.0: i32); - _2 = Add(move _3, const 1_i32); @@ -38,7 +39,8 @@ StorageLive(_8); StorageLive(_9); _9 = _1; - _8 = (move _9, const 1_i32); +- _8 = (move _9, const 1_i32); ++ _8 = (_1, const 1_i32); StorageDead(_9); - _7 = (_8.1: i32); - _6 = Add(move _7, const 2_i32); diff --git a/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-unwind.diff similarity index 85% rename from tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/aggregate.foo.GVN.panic-unwind.diff index 5e2db148de8..4f0f7fa8fa2 100644 --- a/tests/mir-opt/const_prop/aggregate.foo.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/aggregate.foo.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `foo` before ConstProp -+ // MIR for `foo` after ConstProp +- // MIR for `foo` before GVN ++ // MIR for `foo` after GVN fn foo(_1: u8) -> () { debug x => _1; @@ -25,7 +25,8 @@ StorageLive(_4); StorageLive(_5); _5 = _1; - _4 = (const 0_i32, move _5); +- _4 = (const 0_i32, move _5); ++ _4 = (const 0_i32, _1); StorageDead(_5); - _3 = (_4.0: i32); - _2 = Add(move _3, const 1_i32); @@ -38,7 +39,8 @@ StorageLive(_8); StorageLive(_9); _9 = _1; - _8 = (move _9, const 1_i32); +- _8 = (move _9, const 1_i32); ++ _8 = (_1, const 1_i32); StorageDead(_9); - _7 = (_8.1: i32); - _6 = Add(move _7, const 2_i32); diff --git a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-abort.diff similarity index 85% rename from tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/aggregate.main.GVN.panic-abort.diff index a4911a6d48a..854e27445af 100644 --- a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -13,7 +13,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); StorageLive(_3); _3 = (const 0_i32, const 1_u8, const 2_i32); @@ -35,7 +36,8 @@ StorageDead(_5); StorageDead(_4); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-unwind.diff similarity index 85% rename from tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/aggregate.main.GVN.panic-unwind.diff index b8b9fa5cc1c..f6c4b2c9240 100644 --- a/tests/mir-opt/const_prop/aggregate.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/aggregate.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -13,7 +13,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); StorageLive(_3); _3 = (const 0_i32, const 1_u8, const 2_i32); @@ -35,7 +36,8 @@ StorageDead(_5); StorageDead(_4); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/aggregate.rs b/tests/mir-opt/const_prop/aggregate.rs index fa716b0843d..3dd37b5910e 100644 --- a/tests/mir-opt/const_prop/aggregate.rs +++ b/tests/mir-opt/const_prop/aggregate.rs @@ -1,8 +1,8 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -O -// EMIT_MIR aggregate.main.ConstProp.diff +// EMIT_MIR aggregate.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; @@ -15,7 +15,7 @@ fn main() { } // Verify that we still propagate if part of the aggregate is not known. -// EMIT_MIR aggregate.foo.ConstProp.diff +// EMIT_MIR aggregate.foo.GVN.diff fn foo(x: u8) { // CHECK-LABEL: fn foo( // CHECK: debug first => [[first:_.*]]; diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-abort.diff similarity index 71% rename from tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-abort.diff rename to tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-abort.diff index b2f58f8f771..f9537661e8c 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,12 +18,11 @@ _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; -+ _4 = const 4_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind unreachable]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-unwind.diff similarity index 71% rename from tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff rename to tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-unwind.diff index f9e3f8f171a..07886779fea 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/array_index.main.GVN.32bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,12 +18,11 @@ _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; -+ _4 = const 4_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind continue]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-abort.diff similarity index 71% rename from tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-abort.diff rename to tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-abort.diff index b2f58f8f771..f9537661e8c 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,12 +18,11 @@ _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; -+ _4 = const 4_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind unreachable]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-unwind.diff similarity index 71% rename from tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff rename to tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-unwind.diff index f9e3f8f171a..07886779fea 100644 --- a/tests/mir-opt/const_prop/array_index.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/array_index.main.GVN.64bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,12 +18,11 @@ _2 = [const 0_u32, const 1_u32, const 2_u32, const 3_u32]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; -+ _4 = const 4_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 4_usize, const 2_usize) -> [success: bb1, unwind continue]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/array_index.rs b/tests/mir-opt/const_prop/array_index.rs index c4c46d78f75..2ae5087751f 100644 --- a/tests/mir-opt/const_prop/array_index.rs +++ b/tests/mir-opt/const_prop/array_index.rs @@ -1,8 +1,8 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR array_index.main.ConstProp.diff +// EMIT_MIR array_index.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-abort.diff similarity index 91% rename from tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-abort.diff index cead70110dc..4838efba6f9 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,7 +18,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = const 0_i32; StorageLive(_2); StorageLive(_3); @@ -47,7 +48,8 @@ StorageDead(_3); _0 = const (); StorageDead(_2); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-unwind.diff similarity index 91% rename from tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-unwind.diff index c9c4ba8548c..7f403d6efc1 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,7 +18,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = const 0_i32; StorageLive(_2); StorageLive(_3); @@ -47,7 +48,8 @@ StorageDead(_3); _0 = const (); StorageDead(_2); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs index 0e8765a0771..2ba53a80c43 100644 --- a/tests/mir-opt/const_prop/bad_op_div_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_div_by_zero.rs @@ -1,7 +1,7 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// EMIT_MIR bad_op_div_by_zero.main.ConstProp.diff +// EMIT_MIR bad_op_div_by_zero.main.GVN.diff #[allow(unconditional_panic)] fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-abort.diff similarity index 91% rename from tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-abort.diff index 2666fd9eb91..59f2eb86f50 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,7 +18,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = const 0_i32; StorageLive(_2); StorageLive(_3); @@ -47,7 +48,8 @@ StorageDead(_3); _0 = const (); StorageDead(_2); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-unwind.diff similarity index 91% rename from tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-unwind.diff index 679df90f16f..9b866082788 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,7 +18,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = const 0_i32; StorageLive(_2); StorageLive(_3); @@ -47,7 +48,8 @@ StorageDead(_3); _0 = const (); StorageDead(_2); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs index d895d9e2155..9ab57750de0 100644 --- a/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs +++ b/tests/mir-opt/const_prop/bad_op_mod_by_zero.rs @@ -1,7 +1,7 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// EMIT_MIR bad_op_mod_by_zero.main.ConstProp.diff +// EMIT_MIR bad_op_mod_by_zero.main.GVN.diff #[allow(unconditional_panic)] fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff similarity index 85% rename from tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff rename to tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff index e443c8991f9..a42f9291324 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,15 +22,18 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _9 = const _; _3 = &(*_9); _2 = &raw const (*_3); _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); StorageDead(_2); - StorageDead(_3); +- StorageDead(_3); ++ nop; StorageLive(_5); StorageLive(_6); _6 = const 3_usize; @@ -47,7 +50,8 @@ StorageDead(_6); _0 = const (); StorageDead(_5); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff similarity index 85% rename from tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff rename to tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff index 592f43f4739..f2d6de6621b 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.32bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,15 +22,18 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _9 = const _; _3 = &(*_9); _2 = &raw const (*_3); _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); StorageDead(_2); - StorageDead(_3); +- StorageDead(_3); ++ nop; StorageLive(_5); StorageLive(_6); _6 = const 3_usize; @@ -47,7 +50,8 @@ StorageDead(_6); _0 = const (); StorageDead(_5); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff similarity index 85% rename from tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff rename to tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff index e443c8991f9..a42f9291324 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,15 +22,18 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _9 = const _; _3 = &(*_9); _2 = &raw const (*_3); _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); StorageDead(_2); - StorageDead(_3); +- StorageDead(_3); ++ nop; StorageLive(_5); StorageLive(_6); _6 = const 3_usize; @@ -47,7 +50,8 @@ StorageDead(_6); _0 = const (); StorageDead(_5); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff similarity index 85% rename from tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff rename to tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff index 592f43f4739..f2d6de6621b 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.main.GVN.64bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,15 +22,18 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _9 = const _; _3 = &(*_9); _2 = &raw const (*_3); _1 = move _2 as *const [i32] (PointerCoercion(Unsize)); StorageDead(_2); - StorageDead(_3); +- StorageDead(_3); ++ nop; StorageLive(_5); StorageLive(_6); _6 = const 3_usize; @@ -47,7 +50,8 @@ StorageDead(_6); _0 = const (); StorageDead(_5); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs index 266105c11f2..c6d63f0bf18 100644 --- a/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs +++ b/tests/mir-opt/const_prop/bad_op_unsafe_oob_for_slices.rs @@ -1,8 +1,8 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR bad_op_unsafe_oob_for_slices.main.ConstProp.diff +// EMIT_MIR bad_op_unsafe_oob_for_slices.main.GVN.diff #[allow(unconditional_panic)] fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/boolean_identities.rs b/tests/mir-opt/const_prop/boolean_identities.rs index 2aa038034d8..f6575ac8e54 100644 --- a/tests/mir-opt/const_prop/boolean_identities.rs +++ b/tests/mir-opt/const_prop/boolean_identities.rs @@ -1,13 +1,14 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR boolean_identities.test.ConstProp.diff +// EMIT_MIR boolean_identities.test.GVN.diff pub fn test(x: bool, y: bool) -> bool { // CHECK-LABEL: fn test( // CHECK: debug a => [[a:_.*]]; // CHECK: debug b => [[b:_.*]]; - // CHECK: [[a]] = const true; - // CHECK: [[b]] = const false; - // CHECK: _0 = const false; + // FIXME(cjgillot) simplify algebraic identity + // CHECK-NOT: [[a]] = const true; + // CHECK-NOT: [[b]] = const false; + // CHECK-NOT: _0 = const false; let a = (y | true); let b = (x & false); a & b diff --git a/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff b/tests/mir-opt/const_prop/boolean_identities.test.GVN.diff similarity index 67% rename from tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff rename to tests/mir-opt/const_prop/boolean_identities.test.GVN.diff index 41e1acdff59..eca87af7527 100644 --- a/tests/mir-opt/const_prop/boolean_identities.test.ConstProp.diff +++ b/tests/mir-opt/const_prop/boolean_identities.test.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `test` before ConstProp -+ // MIR for `test` after ConstProp +- // MIR for `test` before GVN ++ // MIR for `test` after GVN fn test(_1: bool, _2: bool) -> bool { debug x => _1; @@ -19,30 +19,32 @@ } bb0: { - StorageLive(_3); +- StorageLive(_3); ++ nop; StorageLive(_4); _4 = _2; - _3 = BitOr(move _4, const true); -+ _3 = const true; ++ _3 = BitOr(_2, const true); StorageDead(_4); - StorageLive(_5); +- StorageLive(_5); ++ nop; StorageLive(_6); _6 = _1; - _5 = BitAnd(move _6, const false); -+ _5 = const false; ++ _5 = BitAnd(_1, const false); StorageDead(_6); StorageLive(_7); -- _7 = _3; -+ _7 = const true; + _7 = _3; StorageLive(_8); -- _8 = _5; + _8 = _5; - _0 = BitAnd(move _7, move _8); -+ _8 = const false; -+ _0 = const false; ++ _0 = BitAnd(_3, _5); StorageDead(_8); StorageDead(_7); - StorageDead(_5); - StorageDead(_3); +- StorageDead(_5); +- StorageDead(_3); ++ nop; ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff similarity index 95% rename from tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff index c9670a5ee43..b3fdaa5ee82 100644 --- a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/boxes.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff similarity index 95% rename from tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff index 64fe72be5c8..d0350c97253 100644 --- a/tests/mir-opt/const_prop/boxes.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/boxes.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/boxes.rs b/tests/mir-opt/const_prop/boxes.rs index 90a8e33e823..5227d7b8b8b 100644 --- a/tests/mir-opt/const_prop/boxes.rs +++ b/tests/mir-opt/const_prop/boxes.rs @@ -1,4 +1,4 @@ -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -O // EMIT_MIR_FOR_EACH_PANIC_STRATEGY @@ -6,7 +6,7 @@ // Note: this test verifies that we, in fact, do not const prop `#[rustc_box]` -// EMIT_MIR boxes.main.ConstProp.diff +// EMIT_MIR boxes.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/cast.main.ConstProp.diff b/tests/mir-opt/const_prop/cast.main.GVN.diff similarity index 87% rename from tests/mir-opt/const_prop/cast.main.ConstProp.diff rename to tests/mir-opt/const_prop/cast.main.GVN.diff index c63adcf1191..bc442c4e446 100644 --- a/tests/mir-opt/const_prop/cast.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/cast.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/cast.rs b/tests/mir-opt/const_prop/cast.rs index b81c2740a73..00a8bcd1adb 100644 --- a/tests/mir-opt/const_prop/cast.rs +++ b/tests/mir-opt/const_prop/cast.rs @@ -1,5 +1,5 @@ -// unit-test: ConstProp -// EMIT_MIR cast.main.ConstProp.diff +// unit-test: GVN +// EMIT_MIR cast.main.GVN.diff fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff similarity index 92% rename from tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff index 5a958cc7a47..d5117b2f638 100644 --- a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff similarity index 92% rename from tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff index ab48186aed9..2118d37672c 100644 --- a/tests/mir-opt/const_prop/checked_add.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/checked_add.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/checked_add.rs b/tests/mir-opt/const_prop/checked_add.rs index 571a5cc4e4d..0abcb5dd3d4 100644 --- a/tests/mir-opt/const_prop/checked_add.rs +++ b/tests/mir-opt/const_prop/checked_add.rs @@ -1,8 +1,8 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -C overflow-checks=on -// EMIT_MIR checked_add.main.ConstProp.diff +// EMIT_MIR checked_add.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-abort.diff similarity index 77% rename from tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-abort.diff index ba2e89f0a74..803e1d711de 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `hello` before ConstProp -+ // MIR for `hello` after ConstProp +- // MIR for `hello` before GVN ++ // MIR for `hello` after GVN fn hello() -> () { let mut _0: (); @@ -8,9 +8,8 @@ bb0: { StorageLive(_1); -- _1 = const _; + _1 = const _; - switchInt(move _1) -> [0: bb2, otherwise: bb1]; -+ _1 = const false; + switchInt(const false) -> [0: bb2, otherwise: bb1]; } diff --git a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff similarity index 77% rename from tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff index e0a610f60a7..f40eb38c634 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.hello.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/control_flow_simplification.hello.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `hello` before ConstProp -+ // MIR for `hello` after ConstProp +- // MIR for `hello` before GVN ++ // MIR for `hello` after GVN fn hello() -> () { let mut _0: (); @@ -8,9 +8,8 @@ bb0: { StorageLive(_1); -- _1 = const _; + _1 = const _; - switchInt(move _1) -> [0: bb2, otherwise: bb1]; -+ _1 = const false; + switchInt(const false) -> [0: bb2, otherwise: bb1]; } diff --git a/tests/mir-opt/const_prop/control_flow_simplification.rs b/tests/mir-opt/const_prop/control_flow_simplification.rs index 5fc13e20275..3cb9a4911a9 100644 --- a/tests/mir-opt/const_prop/control_flow_simplification.rs +++ b/tests/mir-opt/const_prop/control_flow_simplification.rs @@ -1,6 +1,6 @@ // skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -Zmir-opt-level=1 trait NeedsDrop: Sized { @@ -9,7 +9,7 @@ trait NeedsDrop: Sized { impl NeedsDrop for This {} -// EMIT_MIR control_flow_simplification.hello.ConstProp.diff +// EMIT_MIR control_flow_simplification.hello.GVN.diff // EMIT_MIR control_flow_simplification.hello.PreCodegen.before.mir fn hello(){ if ::NEEDS { diff --git a/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff b/tests/mir-opt/const_prop/discriminant.main.GVN.32bit.diff similarity index 93% rename from tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff rename to tests/mir-opt/const_prop/discriminant.main.GVN.32bit.diff index e02e7f320b8..70c3c3fe7e4 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff b/tests/mir-opt/const_prop/discriminant.main.GVN.64bit.diff similarity index 93% rename from tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff rename to tests/mir-opt/const_prop/discriminant.main.GVN.64bit.diff index e02e7f320b8..70c3c3fe7e4 100644 --- a/tests/mir-opt/const_prop/discriminant.main.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/discriminant.main.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/discriminant.rs b/tests/mir-opt/const_prop/discriminant.rs index 0ed683d629c..53874e9528e 100644 --- a/tests/mir-opt/const_prop/discriminant.rs +++ b/tests/mir-opt/const_prop/discriminant.rs @@ -1,4 +1,4 @@ -// unit-test: ConstProp +// unit-test: GVN // FIXME(wesleywiser): Ideally, we could const-prop away all of this and just be left with // `let x = 42` but that doesn't work because const-prop doesn't support `Operand::Indirect` @@ -6,7 +6,7 @@ // Fixing either of those will allow us to const-prop this away. // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR discriminant.main.ConstProp.diff +// EMIT_MIR discriminant.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: bb0: { diff --git a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/indirect.main.GVN.panic-abort.diff similarity index 93% rename from tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/indirect.main.GVN.panic-abort.diff index 530cfc6539a..8301a4c1aa8 100644 --- a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/indirect.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/indirect.main.GVN.panic-unwind.diff similarity index 93% rename from tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/indirect.main.GVN.panic-unwind.diff index 08cf72e47a9..8dcbfd2c2c1 100644 --- a/tests/mir-opt/const_prop/indirect.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/indirect.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/indirect.rs b/tests/mir-opt/const_prop/indirect.rs index d3c42e3eb0b..d089418e898 100644 --- a/tests/mir-opt/const_prop/indirect.rs +++ b/tests/mir-opt/const_prop/indirect.rs @@ -1,8 +1,8 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -C overflow-checks=on -// EMIT_MIR indirect.main.ConstProp.diff +// EMIT_MIR indirect.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff b/tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff similarity index 78% rename from tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff rename to tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff index 4eafb8d0917..7dd80d64360 100644 --- a/tests/mir-opt/const_prop/indirect_mutation.bar.ConstProp.diff +++ b/tests/mir-opt/const_prop/indirect_mutation.bar.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `bar` before ConstProp -+ // MIR for `bar` after ConstProp +- // MIR for `bar` before GVN ++ // MIR for `bar` after GVN fn bar() -> () { let mut _0: (); @@ -19,12 +19,15 @@ bb0: { StorageLive(_1); - _1 = (const 1_i32,); +- _1 = (const 1_i32,); ++ _1 = const (1_i32,); StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _3 = &raw mut (_1.0: i32); (*_3) = const 5_i32; - StorageDead(_3); +- StorageDead(_3); ++ nop; _2 = const (); StorageDead(_2); StorageLive(_4); diff --git a/tests/mir-opt/const_prop/indirect_mutation.foo.ConstProp.diff b/tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff similarity index 75% rename from tests/mir-opt/const_prop/indirect_mutation.foo.ConstProp.diff rename to tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff index 445d9895d6a..c4b647d9d2d 100644 --- a/tests/mir-opt/const_prop/indirect_mutation.foo.ConstProp.diff +++ b/tests/mir-opt/const_prop/indirect_mutation.foo.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `foo` before ConstProp -+ // MIR for `foo` after ConstProp +- // MIR for `foo` before GVN ++ // MIR for `foo` after GVN fn foo() -> () { let mut _0: (); @@ -16,11 +16,14 @@ bb0: { StorageLive(_1); - _1 = (const 1_i32,); - StorageLive(_2); +- _1 = (const 1_i32,); +- StorageLive(_2); ++ _1 = const (1_i32,); ++ nop; _2 = &mut (_1.0: i32); (*_2) = const 5_i32; - StorageDead(_2); +- StorageDead(_2); ++ nop; StorageLive(_3); StorageLive(_4); _4 = (_1.0: i32); diff --git a/tests/mir-opt/const_prop/indirect_mutation.rs b/tests/mir-opt/const_prop/indirect_mutation.rs index ec9da6e8e5c..a4236060c81 100644 --- a/tests/mir-opt/const_prop/indirect_mutation.rs +++ b/tests/mir-opt/const_prop/indirect_mutation.rs @@ -1,13 +1,13 @@ -// unit-test: ConstProp +// unit-test: GVN // Check that we do not propagate past an indirect mutation. #![feature(raw_ref_op)] -// EMIT_MIR indirect_mutation.foo.ConstProp.diff +// EMIT_MIR indirect_mutation.foo.GVN.diff fn foo() { // CHECK-LABEL: fn foo( // CHECK: debug u => _1; // CHECK: debug y => _3; - // CHECK: _1 = (const 1_i32,); + // CHECK: _1 = const (1_i32,); // CHECK: _2 = &mut (_1.0: i32); // CHECK: (*_2) = const 5_i32; // CHECK: _4 = (_1.0: i32); @@ -18,7 +18,7 @@ fn foo() { let y = { u.0 } == 5; } -// EMIT_MIR indirect_mutation.bar.ConstProp.diff +// EMIT_MIR indirect_mutation.bar.GVN.diff fn bar() { // CHECK-LABEL: fn bar( // CHECK: debug v => _1; diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff similarity index 94% rename from tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff index 11cdf9e09db..4c2df228eb8 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff similarity index 94% rename from tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff index 181a2f287d6..c4e666b489e 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/inherit_overflow.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/inherit_overflow.rs b/tests/mir-opt/const_prop/inherit_overflow.rs index 5b561ae14ad..c5b1dbe37a9 100644 --- a/tests/mir-opt/const_prop/inherit_overflow.rs +++ b/tests/mir-opt/const_prop/inherit_overflow.rs @@ -1,10 +1,10 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -Zmir-enable-passes=+Inline // After inlining, this will contain a `CheckedBinaryOp`. // Propagating the overflow is ok as codegen will just skip emitting the panic. -// EMIT_MIR inherit_overflow.main.ConstProp.diff +// EMIT_MIR inherit_overflow.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: {{_.*}} = const (0_u8, true); diff --git a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff b/tests/mir-opt/const_prop/invalid_constant.main.GVN.diff similarity index 83% rename from tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff rename to tests/mir-opt/const_prop/invalid_constant.main.GVN.diff index 10e978a683a..da5bf1cf42c 100644 --- a/tests/mir-opt/const_prop/invalid_constant.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/invalid_constant.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -35,17 +35,14 @@ StorageLive(_1); StorageLive(_2); _2 = InvalidChar { int: const 1114113_u32 }; -- _1 = (_2.1: char); -+ _1 = const {transmute(0x00110001): char}; + _1 = (_2.1: char); StorageDead(_2); StorageLive(_3); StorageLive(_4); StorageLive(_5); _5 = InvalidTag { int: const 4_u32 }; -- _4 = (_5.1: E); -- _3 = [move _4]; -+ _4 = const Scalar(0x00000004): E; -+ _3 = [const Scalar(0x00000004): E]; + _4 = (_5.1: E); + _3 = [move _4]; StorageDead(_4); StorageDead(_5); nop; diff --git a/tests/mir-opt/const_prop/invalid_constant.rs b/tests/mir-opt/const_prop/invalid_constant.rs index ff6b31a1ee2..142f148d064 100644 --- a/tests/mir-opt/const_prop/invalid_constant.rs +++ b/tests/mir-opt/const_prop/invalid_constant.rs @@ -1,5 +1,5 @@ // skip-filecheck -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -Zmir-enable-passes=+RemoveZsts // Verify that we can pretty print invalid constants. @@ -15,7 +15,7 @@ enum E { A, B, C } enum Empty {} // EMIT_MIR invalid_constant.main.RemoveZsts.diff -// EMIT_MIR invalid_constant.main.ConstProp.diff +// EMIT_MIR invalid_constant.main.GVN.diff fn main() { // An invalid char. union InvalidChar { diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_66971.main.GVN.panic-abort.diff similarity index 78% rename from tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/issue_66971.main.GVN.panic-abort.diff index ff93c85e586..30e8916e2d0 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -11,8 +11,9 @@ StorageLive(_1); StorageLive(_2); StorageLive(_3); - _3 = (); +- _3 = (); - _2 = (move _3, const 0_u8, const 0_u8); ++ _3 = const (); + _2 = const ((), 0_u8, 0_u8); StorageDead(_3); - _1 = encode(move _2) -> [return: bb1, unwind unreachable]; @@ -28,10 +29,6 @@ + } + + ALLOC0 (size: 2, align: 1) { -+ 00 00 │ .. -+ } -+ -+ ALLOC1 (size: 2, align: 1) { + 00 00 │ .. } diff --git a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_66971.main.GVN.panic-unwind.diff similarity index 78% rename from tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/issue_66971.main.GVN.panic-unwind.diff index 8790aad4559..4eb29b174a9 100644 --- a/tests/mir-opt/const_prop/issue_66971.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/issue_66971.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -11,8 +11,9 @@ StorageLive(_1); StorageLive(_2); StorageLive(_3); - _3 = (); +- _3 = (); - _2 = (move _3, const 0_u8, const 0_u8); ++ _3 = const (); + _2 = const ((), 0_u8, 0_u8); StorageDead(_3); - _1 = encode(move _2) -> [return: bb1, unwind continue]; @@ -28,10 +29,6 @@ + } + + ALLOC0 (size: 2, align: 1) { -+ 00 00 │ .. -+ } -+ -+ ALLOC1 (size: 2, align: 1) { + 00 00 │ .. } diff --git a/tests/mir-opt/const_prop/issue_66971.rs b/tests/mir-opt/const_prop/issue_66971.rs index 49d598ff230..30f8ea1606a 100644 --- a/tests/mir-opt/const_prop/issue_66971.rs +++ b/tests/mir-opt/const_prop/issue_66971.rs @@ -1,8 +1,8 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // Due to a bug in propagating scalar pairs the assertion below used to fail. In the expected -// outputs below, after ConstProp this is how _2 would look like with the bug: +// outputs below, after GVN this is how _2 would look like with the bug: // // _2 = (const Scalar(0x00) : (), const 0u8); // @@ -12,7 +12,7 @@ fn encode(this: ((), u8, u8)) { assert!(this.2 == 0); } -// EMIT_MIR issue_66971.main.ConstProp.diff +// EMIT_MIR issue_66971.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: = encode(const ((), 0_u8, 0_u8)) diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff similarity index 92% rename from tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff index 3de9cdd79bc..fc0c8afd4cf 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff similarity index 92% rename from tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff index 72cf48b5cba..cf4089598e7 100644 --- a/tests/mir-opt/const_prop/issue_67019.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/issue_67019.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/issue_67019.rs b/tests/mir-opt/const_prop/issue_67019.rs index f0a09e6e852..e589ed4edcc 100644 --- a/tests/mir-opt/const_prop/issue_67019.rs +++ b/tests/mir-opt/const_prop/issue_67019.rs @@ -1,5 +1,5 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN // This used to ICE in const-prop @@ -7,7 +7,7 @@ fn test(this: ((u8, u8),)) { assert!((this.0).0 == 1); } -// EMIT_MIR issue_67019.main.ConstProp.diff +// EMIT_MIR issue_67019.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: = test(const ((1_u8, 2_u8),)) diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-abort.diff similarity index 67% rename from tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-abort.diff rename to tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-abort.diff index 20e2ee32698..cf36109fdcb 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,17 +18,16 @@ _2 = [const 0_u8; 5000]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; -+ _4 = const 5000_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind unreachable]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { - _1 = _2[_3]; -+ _1 = _2[2 of 3]; ++ _1 = const 0_u8; StorageDead(_3); StorageDead(_2); _0 = const (); diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-unwind.diff similarity index 67% rename from tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff rename to tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-unwind.diff index 1bdbbbf7863..40ed9697180 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.GVN.32bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,17 +18,16 @@ _2 = [const 0_u8; 5000]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; -+ _4 = const 5000_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind continue]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { - _1 = _2[_3]; -+ _1 = _2[2 of 3]; ++ _1 = const 0_u8; StorageDead(_3); StorageDead(_2); _0 = const (); diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-abort.diff similarity index 67% rename from tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-abort.diff rename to tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-abort.diff index 20e2ee32698..cf36109fdcb 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,17 +18,16 @@ _2 = [const 0_u8; 5000]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind unreachable]; -+ _4 = const 5000_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind unreachable]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { - _1 = _2[_3]; -+ _1 = _2[2 of 3]; ++ _1 = const 0_u8; StorageDead(_3); StorageDead(_2); _0 = const (); diff --git a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-unwind.diff similarity index 67% rename from tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff rename to tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-unwind.diff index 1bdbbbf7863..40ed9697180 100644 --- a/tests/mir-opt/const_prop/large_array_index.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/large_array_index.main.GVN.64bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,17 +18,16 @@ _2 = [const 0_u8; 5000]; StorageLive(_3); _3 = const 2_usize; -- _4 = Len(_2); + _4 = Len(_2); - _5 = Lt(_3, _4); - assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, _3) -> [success: bb1, unwind continue]; -+ _4 = const 5000_usize; -+ _5 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 5000_usize, const 2_usize) -> [success: bb1, unwind continue]; ++ _5 = Lt(const 2_usize, _4); ++ assert(move _5, "index out of bounds: the length is {} but the index is {}", move _4, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { - _1 = _2[_3]; -+ _1 = _2[2 of 3]; ++ _1 = const 0_u8; StorageDead(_3); StorageDead(_2); _0 = const (); diff --git a/tests/mir-opt/const_prop/large_array_index.rs b/tests/mir-opt/const_prop/large_array_index.rs index d98d166ff7c..12507b9434f 100644 --- a/tests/mir-opt/const_prop/large_array_index.rs +++ b/tests/mir-opt/const_prop/large_array_index.rs @@ -1,9 +1,9 @@ // skip-filecheck -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR large_array_index.main.ConstProp.diff +// EMIT_MIR large_array_index.main.GVN.diff fn main() { // check that we don't propagate this, because it's too large let x: u8 = [0_u8; 5000][2]; diff --git a/tests/mir-opt/const_prop/mult_by_zero.rs b/tests/mir-opt/const_prop/mult_by_zero.rs index 2e9c63a1ca1..2fdb75c3100 100644 --- a/tests/mir-opt/const_prop/mult_by_zero.rs +++ b/tests/mir-opt/const_prop/mult_by_zero.rs @@ -1,9 +1,10 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR mult_by_zero.test.ConstProp.diff +// EMIT_MIR mult_by_zero.test.GVN.diff fn test(x: i32) -> i32 { // CHECK: fn test( - // CHECK: _0 = const 0_i32; + // FIXME(cjgillot) simplify algebraic identity + // CHECK-NOT: _0 = const 0_i32; x * 0 } diff --git a/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff b/tests/mir-opt/const_prop/mult_by_zero.test.GVN.diff similarity index 72% rename from tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff rename to tests/mir-opt/const_prop/mult_by_zero.test.GVN.diff index 73b1da06423..e9fb34749c1 100644 --- a/tests/mir-opt/const_prop/mult_by_zero.test.ConstProp.diff +++ b/tests/mir-opt/const_prop/mult_by_zero.test.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `test` before ConstProp -+ // MIR for `test` after ConstProp +- // MIR for `test` before GVN ++ // MIR for `test` after GVN fn test(_1: i32) -> i32 { debug x => _1; @@ -10,7 +10,7 @@ StorageLive(_2); _2 = _1; - _0 = Mul(move _2, const 0_i32); -+ _0 = const 0_i32; ++ _0 = Mul(_1, const 0_i32); StorageDead(_2); return; } diff --git a/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable.main.GVN.diff similarity index 78% rename from tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff rename to tests/mir-opt/const_prop/mutable_variable.main.GVN.diff index ad8d9ddb074..11464e32400 100644 --- a/tests/mir-opt/const_prop/mutable_variable.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -17,8 +17,7 @@ _1 = const 42_i32; _1 = const 99_i32; StorageLive(_2); -- _2 = _1; -+ _2 = const 99_i32; + _2 = _1; _0 = const (); StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/const_prop/mutable_variable.rs b/tests/mir-opt/const_prop/mutable_variable.rs index 6c74ea5b9f4..194f39f826e 100644 --- a/tests/mir-opt/const_prop/mutable_variable.rs +++ b/tests/mir-opt/const_prop/mutable_variable.rs @@ -1,13 +1,13 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR mutable_variable.main.ConstProp.diff +// EMIT_MIR mutable_variable.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; // CHECK: debug y => [[y:_.*]]; // CHECK: [[x]] = const 42_i32; // CHECK: [[x]] = const 99_i32; - // CHECK: [[y]] = const 99_i32; + // CHECK: [[y]] = [[x]]; let mut x = 42; x = 99; let y = x; diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.GVN.diff similarity index 72% rename from tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff rename to tests/mir-opt/const_prop/mutable_variable_aggregate.main.GVN.diff index c3ace9687e6..b6ff7b0fc23 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,8 +18,7 @@ + _1 = const (42_i32, 43_i32); (_1.1: i32) = const 99_i32; StorageLive(_2); -- _2 = _1; -+ _2 = const (42_i32, 99_i32); + _2 = _1; _0 = const (); StorageDead(_2); StorageDead(_1); @@ -28,10 +27,6 @@ + } + + ALLOC0 (size: 8, align: 4) { -+ 2a 00 00 00 63 00 00 00 │ *...c... -+ } -+ -+ ALLOC1 (size: 8, align: 4) { + 2a 00 00 00 2b 00 00 00 │ *...+... } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs index a3829650290..b59132007aa 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate.rs @@ -1,13 +1,13 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR mutable_variable_aggregate.main.ConstProp.diff +// EMIT_MIR mutable_variable_aggregate.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; // CHECK: debug y => [[y:_.*]]; // CHECK: [[x]] = const (42_i32, 43_i32); // CHECK: ([[x]].1: i32) = const 99_i32; - // CHECK: [[y]] = const (42_i32, 99_i32); + // CHECK: [[y]] = [[x]]; let mut x = (42, 43); x.1 = 99; let y = x; diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff similarity index 63% rename from tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff rename to tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff index 106e27f8f27..bc60546cd19 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,17 +18,24 @@ bb0: { StorageLive(_1); - _1 = (const 42_i32, const 43_i32); - StorageLive(_2); +- _1 = (const 42_i32, const 43_i32); +- StorageLive(_2); ++ _1 = const (42_i32, 43_i32); ++ nop; _2 = &mut _1; ((*_2).1: i32) = const 99_i32; StorageLive(_3); _3 = _1; _0 = const (); StorageDead(_3); - StorageDead(_2); +- StorageDead(_2); ++ nop; StorageDead(_1); return; } ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 2a 00 00 00 2b 00 00 00 │ *...+... } diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs index 60f414ae286..1867f7300bd 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_mut_ref.rs @@ -1,12 +1,12 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR mutable_variable_aggregate_mut_ref.main.ConstProp.diff +// EMIT_MIR mutable_variable_aggregate_mut_ref.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; // CHECK: debug z => [[z:_.*]]; // CHECK: debug y => [[y:_.*]]; - // CHECK: [[x]] = (const 42_i32, const 43_i32); + // CHECK: [[x]] = const (42_i32, 43_i32); // CHECK: [[z]] = &mut [[x]]; // CHECK: ((*[[z]]).1: i32) = const 99_i32; // CHECK: [[y]] = [[x]]; diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.GVN.panic-abort.diff similarity index 80% rename from tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.GVN.panic-abort.diff index 34288c62fee..6480e480f8c 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -21,8 +21,7 @@ (_1.1: i32) = const 99_i32; (_1.0: i32) = const 42_i32; StorageLive(_2); -- _2 = (_1.1: i32); -+ _2 = const 99_i32; + _2 = (_1.1: i32); _0 = const (); StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.GVN.panic-unwind.diff similarity index 80% rename from tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.GVN.panic-unwind.diff index 7ba2b483dc3..fb757801082 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -21,8 +21,7 @@ (_1.1: i32) = const 99_i32; (_1.0: i32) = const 42_i32; StorageLive(_2); -- _2 = (_1.1: i32); -+ _2 = const 99_i32; + _2 = (_1.1: i32); _0 = const (); StorageDead(_2); StorageDead(_1); diff --git a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs index 888fcde2de6..d0a44d8f4a0 100644 --- a/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs +++ b/tests/mir-opt/const_prop/mutable_variable_aggregate_partial_read.rs @@ -1,7 +1,7 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR mutable_variable_aggregate_partial_read.main.ConstProp.diff +// EMIT_MIR mutable_variable_aggregate_partial_read.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; @@ -9,7 +9,7 @@ fn main() { // CHECK: [[x]] = foo() // CHECK: ([[x]].1: i32) = const 99_i32; // CHECK: ([[x]].0: i32) = const 42_i32; - // CHECK: [[y]] = const 99_i32; + // CHECK: [[y]] = ([[x]].1: i32); let mut x: (i32, i32) = foo(); x.1 = 99; x.0 = 42; diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff similarity index 85% rename from tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff rename to tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff index 1f74bdcfd03..d02c392f6bd 100644 --- a/tests/mir-opt/const_prop/mutable_variable_no_prop.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,12 +22,14 @@ _1 = const 42_u32; StorageLive(_2); StorageLive(_3); - StorageLive(_4); +- StorageLive(_4); ++ nop; _4 = const {ALLOC0: *mut u32}; _3 = (*_4); _1 = move _3; StorageDead(_3); - StorageDead(_4); +- StorageDead(_4); ++ nop; _2 = const (); StorageDead(_2); StorageLive(_5); diff --git a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs index 49e9a701581..180e194928e 100644 --- a/tests/mir-opt/const_prop/mutable_variable_no_prop.rs +++ b/tests/mir-opt/const_prop/mutable_variable_no_prop.rs @@ -1,9 +1,9 @@ -// unit-test: ConstProp +// unit-test: GVN // Verify that we do not propagate the contents of this mutable static. static mut STATIC: u32 = 0x42424242; -// EMIT_MIR mutable_variable_no_prop.main.ConstProp.diff +// EMIT_MIR mutable_variable_no_prop.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-abort.diff similarity index 81% rename from tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-abort.diff index 85bd2b6e722..d1d23675bfd 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,7 +22,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = foo() -> [return: bb1, unwind unreachable]; } @@ -32,18 +33,19 @@ + _2 = const (1_i32, 2_i32); StorageLive(_3); _3 = _1; - (_2.1: i32) = move _3; +- (_2.1: i32) = move _3; ++ (_2.1: i32) = _1; StorageDead(_3); StorageLive(_4); _4 = (_2.1: i32); StorageLive(_5); -- _5 = (_2.0: i32); -+ _5 = const 1_i32; + _5 = (_2.0: i32); _0 = const (); StorageDead(_5); StorageDead(_4); StorageDead(_2); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } + } diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-unwind.diff similarity index 81% rename from tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-unwind.diff index 06e96e57a62..4d69c9ce2ef 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -22,7 +22,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = foo() -> [return: bb1, unwind continue]; } @@ -32,18 +33,19 @@ + _2 = const (1_i32, 2_i32); StorageLive(_3); _3 = _1; - (_2.1: i32) = move _3; +- (_2.1: i32) = move _3; ++ (_2.1: i32) = _1; StorageDead(_3); StorageLive(_4); _4 = (_2.1: i32); StorageLive(_5); -- _5 = (_2.0: i32); -+ _5 = const 1_i32; + _5 = (_2.0: i32); _0 = const (); StorageDead(_5); StorageDead(_4); StorageDead(_2); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } + } diff --git a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs index 04e347fc03d..585363572a5 100644 --- a/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs +++ b/tests/mir-opt/const_prop/mutable_variable_unprop_assign.rs @@ -1,7 +1,7 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR mutable_variable_unprop_assign.main.ConstProp.diff +// EMIT_MIR mutable_variable_unprop_assign.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug a => [[a:_.*]]; @@ -10,10 +10,9 @@ fn main() { // CHECK: debug z => [[z:_.*]]; // CHECK: [[a]] = foo() // CHECK: [[x]] = const (1_i32, 2_i32); - // CHECK: [[tmp:_.*]] = [[a]]; - // CHECK: ([[x]].1: i32) = move [[tmp]]; + // CHECK: ([[x]].1: i32) = [[a]]; // CHECK: [[y]] = ([[x]].1: i32); - // CHECK: [[z]] = const 1_i32; + // CHECK: [[z]] = ([[x]].0: i32); let a = foo(); let mut x: (i32, i32) = (1, 2); x.1 = a; diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-abort.diff similarity index 97% rename from tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-abort.diff index 711db3d21dd..5d94797905d 100644 --- a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `concrete` before ConstProp -+ // MIR for `concrete` after ConstProp +- // MIR for `concrete` before GVN ++ // MIR for `concrete` after GVN fn concrete() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-unwind.diff similarity index 97% rename from tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-unwind.diff index 49458145415..4d890742ee9 100644 --- a/tests/mir-opt/const_prop/offset_of.concrete.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/offset_of.concrete.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `concrete` before ConstProp -+ // MIR for `concrete` after ConstProp +- // MIR for `concrete` before GVN ++ // MIR for `concrete` after GVN fn concrete() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-abort.diff similarity index 84% rename from tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/offset_of.generic.GVN.panic-abort.diff index 768970a7250..025241dd1bf 100644 --- a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `generic` before ConstProp -+ // MIR for `generic` after ConstProp +- // MIR for `generic` before GVN ++ // MIR for `generic` after GVN fn generic() -> () { let mut _0: (); @@ -58,16 +58,20 @@ StorageDead(_4); StorageLive(_5); StorageLive(_6); - _6 = OffsetOf(Delta, [(0, 1)]); - _5 = must_use::(move _6) -> [return: bb3, unwind unreachable]; +- _6 = OffsetOf(Delta, [(0, 1)]); +- _5 = must_use::(move _6) -> [return: bb3, unwind unreachable]; ++ _6 = const 0_usize; ++ _5 = must_use::(const 0_usize) -> [return: bb3, unwind unreachable]; } bb3: { StorageDead(_6); StorageLive(_7); StorageLive(_8); - _8 = OffsetOf(Delta, [(0, 2)]); - _7 = must_use::(move _8) -> [return: bb4, unwind unreachable]; +- _8 = OffsetOf(Delta, [(0, 2)]); +- _7 = must_use::(move _8) -> [return: bb4, unwind unreachable]; ++ _8 = const 2_usize; ++ _7 = must_use::(const 2_usize) -> [return: bb4, unwind unreachable]; } bb4: { diff --git a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-unwind.diff similarity index 84% rename from tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/offset_of.generic.GVN.panic-unwind.diff index 04ccd2b36e0..27f2b2f7355 100644 --- a/tests/mir-opt/const_prop/offset_of.generic.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/offset_of.generic.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `generic` before ConstProp -+ // MIR for `generic` after ConstProp +- // MIR for `generic` before GVN ++ // MIR for `generic` after GVN fn generic() -> () { let mut _0: (); @@ -58,16 +58,20 @@ StorageDead(_4); StorageLive(_5); StorageLive(_6); - _6 = OffsetOf(Delta, [(0, 1)]); - _5 = must_use::(move _6) -> [return: bb3, unwind continue]; +- _6 = OffsetOf(Delta, [(0, 1)]); +- _5 = must_use::(move _6) -> [return: bb3, unwind continue]; ++ _6 = const 0_usize; ++ _5 = must_use::(const 0_usize) -> [return: bb3, unwind continue]; } bb3: { StorageDead(_6); StorageLive(_7); StorageLive(_8); - _8 = OffsetOf(Delta, [(0, 2)]); - _7 = must_use::(move _8) -> [return: bb4, unwind continue]; +- _8 = OffsetOf(Delta, [(0, 2)]); +- _7 = must_use::(move _8) -> [return: bb4, unwind continue]; ++ _8 = const 2_usize; ++ _7 = must_use::(const 2_usize) -> [return: bb4, unwind continue]; } bb4: { diff --git a/tests/mir-opt/const_prop/offset_of.rs b/tests/mir-opt/const_prop/offset_of.rs index 2571c3856f4..43ecbbed186 100644 --- a/tests/mir-opt/const_prop/offset_of.rs +++ b/tests/mir-opt/const_prop/offset_of.rs @@ -1,5 +1,5 @@ // skip-filecheck -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #![feature(offset_of, offset_of_enum)] @@ -39,7 +39,7 @@ enum Zeta { B(char), } -// EMIT_MIR offset_of.concrete.ConstProp.diff +// EMIT_MIR offset_of.concrete.GVN.diff fn concrete() { let x = offset_of!(Alpha, x); let y = offset_of!(Alpha, y); @@ -50,7 +50,7 @@ fn concrete() { let eC = offset_of!(Epsilon, C.c); } -// EMIT_MIR offset_of.generic.ConstProp.diff +// EMIT_MIR offset_of.generic.GVN.diff fn generic() { let gx = offset_of!(Gamma, x); let gy = offset_of!(Gamma, y); diff --git a/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs b/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs index 4cf6d7c1396..2a3499bf2fe 100644 --- a/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs +++ b/tests/mir-opt/const_prop/overwrite_with_const_with_params.rs @@ -1,4 +1,4 @@ -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -O // Regression test for https://github.com/rust-lang/rust/issues/118328 @@ -10,7 +10,7 @@ impl SizeOfConst { const SIZE: usize = std::mem::size_of::(); } -// EMIT_MIR overwrite_with_const_with_params.size_of.ConstProp.diff +// EMIT_MIR overwrite_with_const_with_params.size_of.GVN.diff fn size_of() -> usize { // CHECK-LABEL: fn size_of( // CHECK: _1 = const 0_usize; diff --git a/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff b/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.GVN.diff similarity index 79% rename from tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff rename to tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.GVN.diff index ad8318832d6..caa78b7316e 100644 --- a/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.ConstProp.diff +++ b/tests/mir-opt/const_prop/overwrite_with_const_with_params.size_of.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `size_of` before ConstProp -+ // MIR for `size_of` after ConstProp +- // MIR for `size_of` before GVN ++ // MIR for `size_of` after GVN fn size_of() -> usize { let mut _0: usize; diff --git a/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff similarity index 62% rename from tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff index bd1de7476a2..425bc3ff6c1 100644 --- a/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -13,25 +13,30 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _3 = const _; _2 = &raw const (*_3); _1 = move _2 as usize (PointerExposeAddress); StorageDead(_2); - StorageDead(_3); +- StorageDead(_3); ++ nop; StorageLive(_4); StorageLive(_5); _5 = _1; - _4 = read(move _5) -> [return: bb1, unwind unreachable]; +- _4 = read(move _5) -> [return: bb1, unwind unreachable]; ++ _4 = read(_1) -> [return: bb1, unwind unreachable]; } bb1: { StorageDead(_5); StorageDead(_4); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff similarity index 63% rename from tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff index 850b743feb1..e9360ab8d62 100644 --- a/tests/mir-opt/const_prop/pointer_expose_address.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/pointer_expose_address.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -13,25 +13,30 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; StorageLive(_2); - StorageLive(_3); +- StorageLive(_3); ++ nop; _3 = const _; _2 = &raw const (*_3); _1 = move _2 as usize (PointerExposeAddress); StorageDead(_2); - StorageDead(_3); +- StorageDead(_3); ++ nop; StorageLive(_4); StorageLive(_5); _5 = _1; - _4 = read(move _5) -> [return: bb1, unwind continue]; +- _4 = read(move _5) -> [return: bb1, unwind continue]; ++ _4 = read(_1) -> [return: bb1, unwind continue]; } bb1: { StorageDead(_5); StorageDead(_4); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/pointer_expose_address.rs b/tests/mir-opt/const_prop/pointer_expose_address.rs index 631aac901b9..8944232f71e 100644 --- a/tests/mir-opt/const_prop/pointer_expose_address.rs +++ b/tests/mir-opt/const_prop/pointer_expose_address.rs @@ -1,17 +1,16 @@ // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// unit-test: ConstProp +// unit-test: GVN #[inline(never)] fn read(_: usize) { } -// EMIT_MIR pointer_expose_address.main.ConstProp.diff +// EMIT_MIR pointer_expose_address.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: [[ptr:_.*]] = const _; // CHECK: [[ref:_.*]] = &raw const (*[[ptr]]); // CHECK: [[x:_.*]] = move [[ref]] as usize (PointerExposeAddress); - // CHECK: [[arg:_.*]] = [[x]]; - // CHECK: = read(move [[arg]]) + // CHECK: = read([[x]]) const FOO: &i32 = &1; let x = FOO as *const i32 as usize; read(x); diff --git a/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff b/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff similarity index 77% rename from tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff rename to tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff index e193c82d2c0..38f23505230 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/read_immutable_static.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -14,8 +14,10 @@ bb0: { StorageLive(_1); - StorageLive(_2); - StorageLive(_3); +- StorageLive(_2); +- StorageLive(_3); ++ nop; ++ nop; _3 = const {ALLOC0: &u8}; - _2 = (*_3); + _2 = const 2_u8; @@ -27,9 +29,11 @@ + _4 = const 2_u8; + _1 = const 4_u8; StorageDead(_4); - StorageDead(_2); +- StorageDead(_2); ++ nop; StorageDead(_5); - StorageDead(_3); +- StorageDead(_3); ++ nop; _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/const_prop/read_immutable_static.rs b/tests/mir-opt/const_prop/read_immutable_static.rs index 0fa18dd101a..a3d8fee65d7 100644 --- a/tests/mir-opt/const_prop/read_immutable_static.rs +++ b/tests/mir-opt/const_prop/read_immutable_static.rs @@ -1,8 +1,8 @@ -// unit-test: ConstProp +// unit-test: GVN static FOO: u8 = 2; -// EMIT_MIR read_immutable_static.main.ConstProp.diff +// EMIT_MIR read_immutable_static.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff b/tests/mir-opt/const_prop/ref_deref.main.GVN.diff similarity index 64% rename from tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff rename to tests/mir-opt/const_prop/ref_deref.main.GVN.diff index a54ae8d2fdd..8f9aa20524d 100644 --- a/tests/mir-opt/const_prop/ref_deref.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/ref_deref.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -13,11 +13,14 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; _4 = const _; _2 = &(*_4); - _1 = (*_2); - StorageDead(_2); +- _1 = (*_2); +- StorageDead(_2); ++ _1 = const 4_i32; ++ nop; _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/const_prop/ref_deref.rs b/tests/mir-opt/const_prop/ref_deref.rs index 5bceae749ff..67de110d8bb 100644 --- a/tests/mir-opt/const_prop/ref_deref.rs +++ b/tests/mir-opt/const_prop/ref_deref.rs @@ -1,9 +1,9 @@ -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR ref_deref.main.ConstProp.diff +// EMIT_MIR ref_deref.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug a => [[a:_.*]]; - // CHECK: [[a]] = (*{{_.*}}); + // CHECK: [[a]] = const 4_i32; let a = *(&4); } diff --git a/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff b/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff similarity index 65% rename from tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff rename to tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff index 05a4e17742d..8d38888b7d6 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/ref_deref_project.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -13,11 +13,14 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; _4 = const _; _2 = &((*_4).1: i32); - _1 = (*_2); - StorageDead(_2); +- _1 = (*_2); +- StorageDead(_2); ++ _1 = const 5_i32; ++ nop; _0 = const (); StorageDead(_1); return; diff --git a/tests/mir-opt/const_prop/ref_deref_project.rs b/tests/mir-opt/const_prop/ref_deref_project.rs index 4b5c6730316..0f706b91b38 100644 --- a/tests/mir-opt/const_prop/ref_deref_project.rs +++ b/tests/mir-opt/const_prop/ref_deref_project.rs @@ -1,10 +1,10 @@ // This does not currently propagate (#67862) -// unit-test: ConstProp +// unit-test: GVN -// EMIT_MIR ref_deref_project.main.ConstProp.diff +// EMIT_MIR ref_deref_project.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug a => [[a:_.*]]; - // CHECK: [[a]] = (*{{_.*}}); + // CHECK: [[a]] = const 5_i32; let a = *(&(4, 5).1); } diff --git a/tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff b/tests/mir-opt/const_prop/reify_fn_ptr.main.GVN.diff similarity index 88% rename from tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff rename to tests/mir-opt/const_prop/reify_fn_ptr.main.GVN.diff index e7aa015d078..cde0cb32f75 100644 --- a/tests/mir-opt/const_prop/reify_fn_ptr.main.ConstProp.diff +++ b/tests/mir-opt/const_prop/reify_fn_ptr.main.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/reify_fn_ptr.rs b/tests/mir-opt/const_prop/reify_fn_ptr.rs index 33fdd4142c1..96077d5b773 100644 --- a/tests/mir-opt/const_prop/reify_fn_ptr.rs +++ b/tests/mir-opt/const_prop/reify_fn_ptr.rs @@ -1,5 +1,5 @@ -// unit-test: ConstProp -// EMIT_MIR reify_fn_ptr.main.ConstProp.diff +// unit-test: GVN +// EMIT_MIR reify_fn_ptr.main.GVN.diff fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-abort.diff similarity index 74% rename from tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-abort.diff rename to tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-abort.diff index a55bd029e99..a52e6e35483 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -20,12 +20,11 @@ _3 = [const 42_u32; 8]; StorageLive(_4); _4 = const 2_usize; -- _5 = Len(_3); + _5 = Len(_3); - _6 = Lt(_4, _5); - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable]; -+ _5 = const 8_usize; -+ _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind unreachable]; ++ _6 = Lt(const 2_usize, _5); ++ assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-unwind.diff similarity index 74% rename from tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff rename to tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-unwind.diff index d49ef2e0179..fe0acee71eb 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/repeat.main.GVN.32bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -20,12 +20,11 @@ _3 = [const 42_u32; 8]; StorageLive(_4); _4 = const 2_usize; -- _5 = Len(_3); + _5 = Len(_3); - _6 = Lt(_4, _5); - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; -+ _5 = const 8_usize; -+ _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind continue]; ++ _6 = Lt(const 2_usize, _5); ++ assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-abort.diff similarity index 74% rename from tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-abort.diff rename to tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-abort.diff index a55bd029e99..a52e6e35483 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -20,12 +20,11 @@ _3 = [const 42_u32; 8]; StorageLive(_4); _4 = const 2_usize; -- _5 = Len(_3); + _5 = Len(_3); - _6 = Lt(_4, _5); - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind unreachable]; -+ _5 = const 8_usize; -+ _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind unreachable]; ++ _6 = Lt(const 2_usize, _5); ++ assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, const 2_usize) -> [success: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-unwind.diff similarity index 74% rename from tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff rename to tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-unwind.diff index d49ef2e0179..fe0acee71eb 100644 --- a/tests/mir-opt/const_prop/repeat.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/repeat.main.GVN.64bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -20,12 +20,11 @@ _3 = [const 42_u32; 8]; StorageLive(_4); _4 = const 2_usize; -- _5 = Len(_3); + _5 = Len(_3); - _6 = Lt(_4, _5); - assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, _4) -> [success: bb1, unwind continue]; -+ _5 = const 8_usize; -+ _6 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 8_usize, const 2_usize) -> [success: bb1, unwind continue]; ++ _6 = Lt(const 2_usize, _5); ++ assert(move _6, "index out of bounds: the length is {} but the index is {}", move _5, const 2_usize) -> [success: bb1, unwind continue]; } bb1: { diff --git a/tests/mir-opt/const_prop/repeat.rs b/tests/mir-opt/const_prop/repeat.rs index 9f688bbb53e..2c8717d25bb 100644 --- a/tests/mir-opt/const_prop/repeat.rs +++ b/tests/mir-opt/const_prop/repeat.rs @@ -1,8 +1,8 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR repeat.main.ConstProp.diff +// EMIT_MIR repeat.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug x => [[x:_.*]]; diff --git a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/return_place.add.GVN.panic-abort.diff similarity index 91% rename from tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/return_place.add.GVN.panic-abort.diff index 974a42e5078..51f8227c36b 100644 --- a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/return_place.add.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `add` before ConstProp -+ // MIR for `add` after ConstProp +- // MIR for `add` before GVN ++ // MIR for `add` after GVN fn add() -> u32 { let mut _0: u32; diff --git a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/return_place.add.GVN.panic-unwind.diff similarity index 90% rename from tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/return_place.add.GVN.panic-unwind.diff index 55dbc700285..8174b4edea6 100644 --- a/tests/mir-opt/const_prop/return_place.add.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/return_place.add.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `add` before ConstProp -+ // MIR for `add` after ConstProp +- // MIR for `add` before GVN ++ // MIR for `add` after GVN fn add() -> u32 { let mut _0: u32; diff --git a/tests/mir-opt/const_prop/return_place.rs b/tests/mir-opt/const_prop/return_place.rs index 286543abb99..c207bcbdd62 100644 --- a/tests/mir-opt/const_prop/return_place.rs +++ b/tests/mir-opt/const_prop/return_place.rs @@ -1,8 +1,8 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -C overflow-checks=on -// EMIT_MIR return_place.add.ConstProp.diff +// EMIT_MIR return_place.add.GVN.diff // EMIT_MIR return_place.add.PreCodegen.before.mir fn add() -> u32 { // CHECK-LABEL: fn add( diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-abort.diff similarity index 79% rename from tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-abort.diff index c5c09c8edd7..0a20fb0e59e 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -11,7 +11,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = const 1_u32; StorageLive(_2); StorageLive(_3); @@ -25,7 +26,8 @@ StorageDead(_3); StorageDead(_2); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-unwind.diff similarity index 79% rename from tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-unwind.diff index b256c56765e..8b9519d3adc 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -11,7 +11,8 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); ++ nop; _1 = const 1_u32; StorageLive(_2); StorageLive(_3); @@ -25,7 +26,8 @@ StorageDead(_3); StorageDead(_2); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } } diff --git a/tests/mir-opt/const_prop/scalar_literal_propagation.rs b/tests/mir-opt/const_prop/scalar_literal_propagation.rs index 782cd35d422..70d0eb53591 100644 --- a/tests/mir-opt/const_prop/scalar_literal_propagation.rs +++ b/tests/mir-opt/const_prop/scalar_literal_propagation.rs @@ -1,7 +1,7 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// EMIT_MIR scalar_literal_propagation.main.ConstProp.diff +// EMIT_MIR scalar_literal_propagation.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: = consume(const 1_u32) diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff similarity index 53% rename from tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff rename to tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff index 7d5d036f460..8b2411e50ab 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,33 +18,41 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); _9 = const _; - _4 = _9; - _3 = _4; - _2 = move _3 as &[u32] (PointerCoercion(Unsize)); +- _4 = _9; +- _3 = _4; +- _2 = move _3 as &[u32] (PointerCoercion(Unsize)); ++ _4 = const {ALLOC0: &[u32; 3]}; ++ _3 = const {ALLOC0: &[u32; 3]}; ++ _2 = const {ALLOC0: &[u32; 3]} as &[u32] (PointerCoercion(Unsize)); StorageDead(_3); StorageLive(_6); _6 = const 1_usize; -- _7 = Len((*_2)); + _7 = Len((*_2)); - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; -+ _7 = const 3_usize; -+ _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable]; ++ _8 = Lt(const 1_usize, _7); ++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind unreachable]; } bb1: { - _1 = (*_2)[_6]; -+ _1 = const 2_u32; ++ _1 = (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); - StorageDead(_2); +- StorageDead(_2); ++ nop; _0 = const (); StorageDead(_1); return; } ++ } ++ ++ ALLOC0 (size: 12, align: 4) { ++ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............ } diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff similarity index 53% rename from tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff rename to tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff index fa4c5a71be5..9b20d243f87 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.32bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,33 +18,41 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); _9 = const _; - _4 = _9; - _3 = _4; - _2 = move _3 as &[u32] (PointerCoercion(Unsize)); +- _4 = _9; +- _3 = _4; +- _2 = move _3 as &[u32] (PointerCoercion(Unsize)); ++ _4 = const {ALLOC0: &[u32; 3]}; ++ _3 = const {ALLOC0: &[u32; 3]}; ++ _2 = const {ALLOC0: &[u32; 3]} as &[u32] (PointerCoercion(Unsize)); StorageDead(_3); StorageLive(_6); _6 = const 1_usize; -- _7 = Len((*_2)); + _7 = Len((*_2)); - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; -+ _7 = const 3_usize; -+ _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue]; ++ _8 = Lt(const 1_usize, _7); ++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind continue]; } bb1: { - _1 = (*_2)[_6]; -+ _1 = const 2_u32; ++ _1 = (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); - StorageDead(_2); +- StorageDead(_2); ++ nop; _0 = const (); StorageDead(_1); return; } ++ } ++ ++ ALLOC0 (size: 12, align: 4) { ++ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............ } diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff similarity index 53% rename from tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff rename to tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff index 7d5d036f460..8b2411e50ab 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,33 +18,41 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); _9 = const _; - _4 = _9; - _3 = _4; - _2 = move _3 as &[u32] (PointerCoercion(Unsize)); +- _4 = _9; +- _3 = _4; +- _2 = move _3 as &[u32] (PointerCoercion(Unsize)); ++ _4 = const {ALLOC0: &[u32; 3]}; ++ _3 = const {ALLOC0: &[u32; 3]}; ++ _2 = const {ALLOC0: &[u32; 3]} as &[u32] (PointerCoercion(Unsize)); StorageDead(_3); StorageLive(_6); _6 = const 1_usize; -- _7 = Len((*_2)); + _7 = Len((*_2)); - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind unreachable]; -+ _7 = const 3_usize; -+ _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind unreachable]; ++ _8 = Lt(const 1_usize, _7); ++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind unreachable]; } bb1: { - _1 = (*_2)[_6]; -+ _1 = const 2_u32; ++ _1 = (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); - StorageDead(_2); +- StorageDead(_2); ++ nop; _0 = const (); StorageDead(_1); return; } ++ } ++ ++ ALLOC0 (size: 12, align: 4) { ++ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............ } diff --git a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff similarity index 53% rename from tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff rename to tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff index fa4c5a71be5..9b20d243f87 100644 --- a/tests/mir-opt/const_prop/slice_len.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/const_prop/slice_len.main.GVN.64bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -18,33 +18,41 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); ++ nop; StorageLive(_3); StorageLive(_4); _9 = const _; - _4 = _9; - _3 = _4; - _2 = move _3 as &[u32] (PointerCoercion(Unsize)); +- _4 = _9; +- _3 = _4; +- _2 = move _3 as &[u32] (PointerCoercion(Unsize)); ++ _4 = const {ALLOC0: &[u32; 3]}; ++ _3 = const {ALLOC0: &[u32; 3]}; ++ _2 = const {ALLOC0: &[u32; 3]} as &[u32] (PointerCoercion(Unsize)); StorageDead(_3); StorageLive(_6); _6 = const 1_usize; -- _7 = Len((*_2)); + _7 = Len((*_2)); - _8 = Lt(_6, _7); - assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, _6) -> [success: bb1, unwind continue]; -+ _7 = const 3_usize; -+ _8 = const true; -+ assert(const true, "index out of bounds: the length is {} but the index is {}", const 3_usize, const 1_usize) -> [success: bb1, unwind continue]; ++ _8 = Lt(const 1_usize, _7); ++ assert(move _8, "index out of bounds: the length is {} but the index is {}", move _7, const 1_usize) -> [success: bb1, unwind continue]; } bb1: { - _1 = (*_2)[_6]; -+ _1 = const 2_u32; ++ _1 = (*_2)[1 of 2]; StorageDead(_6); StorageDead(_4); - StorageDead(_2); +- StorageDead(_2); ++ nop; _0 = const (); StorageDead(_1); return; } ++ } ++ ++ ALLOC0 (size: 12, align: 4) { ++ 01 00 00 00 02 00 00 00 03 00 00 00 │ ............ } diff --git a/tests/mir-opt/const_prop/slice_len.rs b/tests/mir-opt/const_prop/slice_len.rs index 0bf44272698..79cd926df21 100644 --- a/tests/mir-opt/const_prop/slice_len.rs +++ b/tests/mir-opt/const_prop/slice_len.rs @@ -1,13 +1,16 @@ -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -Zmir-enable-passes=+InstSimplify // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // EMIT_MIR_FOR_EACH_BIT_WIDTH -// EMIT_MIR slice_len.main.ConstProp.diff +// EMIT_MIR slice_len.main.GVN.diff fn main() { // CHECK-LABEL: fn main( // CHECK: debug a => [[a:_.*]]; - // CHECK: assert(const true, - // CHECK: [[a]] = const 2_u32; + // CHECK: [[slice:_.*]] = const {{.*}} as &[u32] (PointerCoercion(Unsize)); + // FIXME(cjgillot) simplify Len and projection into unsized slice. + // CHECK-NOT: assert(const true, + // CHECK: [[a]] = (*[[slice]])[1 of 2]; + // CHECK-NOT: [[a]] = const 2_u32; let a = (&[1u32, 2, 3] as &[u32])[1]; } diff --git a/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/switch_int.main.GVN.panic-abort.diff similarity index 87% rename from tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/switch_int.main.GVN.panic-abort.diff index 508cc15732c..ee9f2d5c7f5 100644 --- a/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/switch_int.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/switch_int.main.GVN.panic-unwind.diff similarity index 87% rename from tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/switch_int.main.GVN.panic-unwind.diff index 1ce28e979a5..143d04ac984 100644 --- a/tests/mir-opt/const_prop/switch_int.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/switch_int.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/const_prop/switch_int.rs b/tests/mir-opt/const_prop/switch_int.rs index d1cbaae49aa..c81b574d150 100644 --- a/tests/mir-opt/const_prop/switch_int.rs +++ b/tests/mir-opt/const_prop/switch_int.rs @@ -1,11 +1,11 @@ -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -Zmir-enable-passes=+SimplifyConstCondition-after-const-prop // EMIT_MIR_FOR_EACH_PANIC_STRATEGY #[inline(never)] fn foo(_: i32) { } -// EMIT_MIR switch_int.main.ConstProp.diff +// EMIT_MIR switch_int.main.GVN.diff // EMIT_MIR switch_int.main.SimplifyConstCondition-after-const-prop.diff fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.from_char.GVN.32bit.diff similarity index 70% rename from tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff rename to tests/mir-opt/const_prop/transmute.from_char.GVN.32bit.diff index febfebc8534..47dfb421ebc 100644 --- a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.from_char.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `from_char` before ConstProp -+ // MIR for `from_char` after ConstProp +- // MIR for `from_char` before GVN ++ // MIR for `from_char` after GVN fn from_char() -> i32 { let mut _0: i32; diff --git a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.from_char.GVN.64bit.diff similarity index 70% rename from tests/mir-opt/const_prop/transmute.from_char.ConstProp.32bit.diff rename to tests/mir-opt/const_prop/transmute.from_char.GVN.64bit.diff index febfebc8534..47dfb421ebc 100644 --- a/tests/mir-opt/const_prop/transmute.from_char.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.from_char.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `from_char` before ConstProp -+ // MIR for `from_char` after ConstProp +- // MIR for `from_char` before GVN ++ // MIR for `from_char` after GVN fn from_char() -> i32 { let mut _0: i32; diff --git a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.invalid_bool.GVN.32bit.diff similarity index 71% rename from tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.32bit.diff rename to tests/mir-opt/const_prop/transmute.invalid_bool.GVN.32bit.diff index 38a1eb5a15b..f0c6f55f775 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_bool.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `invalid_bool` before ConstProp -+ // MIR for `invalid_bool` after ConstProp +- // MIR for `invalid_bool` before GVN ++ // MIR for `invalid_bool` after GVN fn invalid_bool() -> bool { let mut _0: bool; diff --git a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.invalid_bool.GVN.64bit.diff similarity index 71% rename from tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff rename to tests/mir-opt/const_prop/transmute.invalid_bool.GVN.64bit.diff index 38a1eb5a15b..f0c6f55f775 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_bool.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_bool.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `invalid_bool` before ConstProp -+ // MIR for `invalid_bool` after ConstProp +- // MIR for `invalid_bool` before GVN ++ // MIR for `invalid_bool` after GVN fn invalid_bool() -> bool { let mut _0: bool; diff --git a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.invalid_char.GVN.32bit.diff similarity index 71% rename from tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.32bit.diff rename to tests/mir-opt/const_prop/transmute.invalid_char.GVN.32bit.diff index 2c0998f77ea..a9e32d4d925 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_char.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `invalid_char` before ConstProp -+ // MIR for `invalid_char` after ConstProp +- // MIR for `invalid_char` before GVN ++ // MIR for `invalid_char` after GVN fn invalid_char() -> char { let mut _0: char; diff --git a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.invalid_char.GVN.64bit.diff similarity index 71% rename from tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff rename to tests/mir-opt/const_prop/transmute.invalid_char.GVN.64bit.diff index 2c0998f77ea..a9e32d4d925 100644 --- a/tests/mir-opt/const_prop/transmute.invalid_char.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.invalid_char.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `invalid_char` before ConstProp -+ // MIR for `invalid_char` after ConstProp +- // MIR for `invalid_char` before GVN ++ // MIR for `invalid_char` after GVN fn invalid_char() -> char { let mut _0: char; diff --git a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.less_as_i8.GVN.32bit.diff similarity index 79% rename from tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff rename to tests/mir-opt/const_prop/transmute.less_as_i8.GVN.32bit.diff index 7ac7bed8a5f..5e0c076b981 100644 --- a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.less_as_i8.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `less_as_i8` before ConstProp -+ // MIR for `less_as_i8` after ConstProp +- // MIR for `less_as_i8` before GVN ++ // MIR for `less_as_i8` after GVN fn less_as_i8() -> i8 { let mut _0: i8; diff --git a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.less_as_i8.GVN.64bit.diff similarity index 79% rename from tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.32bit.diff rename to tests/mir-opt/const_prop/transmute.less_as_i8.GVN.64bit.diff index 7ac7bed8a5f..5e0c076b981 100644 --- a/tests/mir-opt/const_prop/transmute.less_as_i8.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.less_as_i8.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `less_as_i8` before ConstProp -+ // MIR for `less_as_i8` after ConstProp +- // MIR for `less_as_i8` before GVN ++ // MIR for `less_as_i8` after GVN fn less_as_i8() -> i8 { let mut _0: i8; diff --git a/tests/mir-opt/const_prop/transmute.rs b/tests/mir-opt/const_prop/transmute.rs index 99988d05994..6ff0ba422f4 100644 --- a/tests/mir-opt/const_prop/transmute.rs +++ b/tests/mir-opt/const_prop/transmute.rs @@ -1,46 +1,46 @@ -// unit-test: ConstProp +// unit-test: GVN // compile-flags: -O --crate-type=lib // ignore-endian-big // EMIT_MIR_FOR_EACH_BIT_WIDTH use std::mem::transmute; -// EMIT_MIR transmute.less_as_i8.ConstProp.diff +// EMIT_MIR transmute.less_as_i8.GVN.diff pub fn less_as_i8() -> i8 { // CHECK-LABEL: fn less_as_i8( // CHECK: _0 = const -1_i8; unsafe { transmute(std::cmp::Ordering::Less) } } -// EMIT_MIR transmute.from_char.ConstProp.diff +// EMIT_MIR transmute.from_char.GVN.diff pub fn from_char() -> i32 { // CHECK-LABEL: fn from_char( // CHECK: _0 = const 82_i32; unsafe { transmute('R') } } -// EMIT_MIR transmute.valid_char.ConstProp.diff +// EMIT_MIR transmute.valid_char.GVN.diff pub fn valid_char() -> char { // CHECK-LABEL: fn valid_char( // CHECK: _0 = const 'R'; unsafe { transmute(0x52_u32) } } -// EMIT_MIR transmute.invalid_char.ConstProp.diff +// EMIT_MIR transmute.invalid_char.GVN.diff pub unsafe fn invalid_char() -> char { // CHECK-LABEL: fn invalid_char( // CHECK: _0 = const {transmute(0x7fffffff): char}; unsafe { transmute(i32::MAX) } } -// EMIT_MIR transmute.invalid_bool.ConstProp.diff +// EMIT_MIR transmute.invalid_bool.GVN.diff pub unsafe fn invalid_bool() -> bool { // CHECK-LABEL: fn invalid_bool( // CHECK: _0 = const {transmute(0xff): bool}; unsafe { transmute(-1_i8) } } -// EMIT_MIR transmute.undef_union_as_integer.ConstProp.diff +// EMIT_MIR transmute.undef_union_as_integer.GVN.diff pub unsafe fn undef_union_as_integer() -> u32 { // CHECK-LABEL: fn undef_union_as_integer( // CHECK: _1 = Union32 { @@ -49,16 +49,16 @@ pub unsafe fn undef_union_as_integer() -> u32 { unsafe { transmute(Union32 { unit: () }) } } -// EMIT_MIR transmute.unreachable_direct.ConstProp.diff +// EMIT_MIR transmute.unreachable_direct.GVN.diff pub unsafe fn unreachable_direct() -> ! { // CHECK-LABEL: fn unreachable_direct( - // CHECK: [[unit:_.*]] = (); - // CHECK: move [[unit]] as Never (Transmute); + // CHECK: = const (); + // CHECK: = const () as Never (Transmute); let x: Never = unsafe { transmute(()) }; match x {} } -// EMIT_MIR transmute.unreachable_ref.ConstProp.diff +// EMIT_MIR transmute.unreachable_ref.GVN.diff pub unsafe fn unreachable_ref() -> ! { // CHECK-LABEL: fn unreachable_ref( // CHECK: = const {0x1 as &Never}; @@ -66,7 +66,7 @@ pub unsafe fn unreachable_ref() -> ! { match *x {} } -// EMIT_MIR transmute.unreachable_mut.ConstProp.diff +// EMIT_MIR transmute.unreachable_mut.GVN.diff pub unsafe fn unreachable_mut() -> ! { // CHECK-LABEL: fn unreachable_mut( // CHECK: = const {0x1 as &mut Never}; @@ -74,7 +74,7 @@ pub unsafe fn unreachable_mut() -> ! { match *x {} } -// EMIT_MIR transmute.unreachable_box.ConstProp.diff +// EMIT_MIR transmute.unreachable_box.GVN.diff pub unsafe fn unreachable_box() -> ! { // CHECK-LABEL: fn unreachable_box( // CHECK: = const Box::( diff --git a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.32bit.diff similarity index 74% rename from tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff rename to tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.32bit.diff index afedf2a3061..c6a428019d8 100644 --- a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `undef_union_as_integer` before ConstProp -+ // MIR for `undef_union_as_integer` after ConstProp +- // MIR for `undef_union_as_integer` before GVN ++ // MIR for `undef_union_as_integer` after GVN fn undef_union_as_integer() -> u32 { let mut _0: u32; @@ -11,7 +11,8 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = (); +- _2 = (); ++ _2 = const (); _1 = Union32 { value: move _2 }; StorageDead(_2); _0 = move _1 as u32 (Transmute); diff --git a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.64bit.diff similarity index 74% rename from tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.32bit.diff rename to tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.64bit.diff index afedf2a3061..c6a428019d8 100644 --- a/tests/mir-opt/const_prop/transmute.undef_union_as_integer.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.undef_union_as_integer.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `undef_union_as_integer` before ConstProp -+ // MIR for `undef_union_as_integer` after ConstProp +- // MIR for `undef_union_as_integer` before GVN ++ // MIR for `undef_union_as_integer` after GVN fn undef_union_as_integer() -> u32 { let mut _0: u32; @@ -11,7 +11,8 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = (); +- _2 = (); ++ _2 = const (); _1 = Union32 { value: move _2 }; StorageDead(_2); _0 = move _1 as u32 (Transmute); diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff similarity index 87% rename from tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff rename to tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff index 16519749b82..2ef83abfac0 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_box` before ConstProp -+ // MIR for `unreachable_box` after ConstProp +- // MIR for `unreachable_box` before GVN ++ // MIR for `unreachable_box` after GVN fn unreachable_box() -> ! { let mut _0: !; diff --git a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff similarity index 87% rename from tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff rename to tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff index 16519749b82..2ef83abfac0 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_box.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_box.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_box` before ConstProp -+ // MIR for `unreachable_box` after ConstProp +- // MIR for `unreachable_box` before GVN ++ // MIR for `unreachable_box` after GVN fn unreachable_box() -> ! { let mut _0: !; diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.32bit.diff similarity index 55% rename from tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff rename to tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.32bit.diff index 896608e7eff..b2e91014625 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_direct` before ConstProp -+ // MIR for `unreachable_direct` after ConstProp +- // MIR for `unreachable_direct` before GVN ++ // MIR for `unreachable_direct` after GVN fn unreachable_direct() -> ! { let mut _0: !; @@ -14,8 +14,10 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = (); - _1 = move _2 as Never (Transmute); +- _2 = (); +- _1 = move _2 as Never (Transmute); ++ _2 = const (); ++ _1 = const () as Never (Transmute); unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.64bit.diff similarity index 55% rename from tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff rename to tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.64bit.diff index 896608e7eff..b2e91014625 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_direct.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_direct.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_direct` before ConstProp -+ // MIR for `unreachable_direct` after ConstProp +- // MIR for `unreachable_direct` before GVN ++ // MIR for `unreachable_direct` after GVN fn unreachable_direct() -> ! { let mut _0: !; @@ -14,8 +14,10 @@ bb0: { StorageLive(_1); StorageLive(_2); - _2 = (); - _1 = move _2 as Never (Transmute); +- _2 = (); +- _1 = move _2 as Never (Transmute); ++ _2 = const (); ++ _1 = const () as Never (Transmute); unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff similarity index 69% rename from tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff rename to tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff index c9d5ccf0bfd..93dfef96cf1 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_mut` before ConstProp -+ // MIR for `unreachable_mut` after ConstProp +- // MIR for `unreachable_mut` before GVN ++ // MIR for `unreachable_mut` after GVN fn unreachable_mut() -> ! { let mut _0: !; @@ -13,11 +13,13 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); - _2 = const 1_usize as &mut Never (Transmute); ++ nop; + _2 = const {0x1 as &mut Never}; _1 = &mut (*_2); - StorageDead(_2); +- StorageDead(_2); ++ nop; unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff similarity index 69% rename from tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff rename to tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff index c9d5ccf0bfd..93dfef96cf1 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_mut.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_mut.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_mut` before ConstProp -+ // MIR for `unreachable_mut` after ConstProp +- // MIR for `unreachable_mut` before GVN ++ // MIR for `unreachable_mut` after GVN fn unreachable_mut() -> ! { let mut _0: !; @@ -13,11 +13,13 @@ bb0: { StorageLive(_1); - StorageLive(_2); +- StorageLive(_2); - _2 = const 1_usize as &mut Never (Transmute); ++ nop; + _2 = const {0x1 as &mut Never}; _1 = &mut (*_2); - StorageDead(_2); +- StorageDead(_2); ++ nop; unreachable; } } diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.32bit.diff similarity index 77% rename from tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff rename to tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.32bit.diff index b684ba34c69..430d16c97a6 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_ref` before ConstProp -+ // MIR for `unreachable_ref` after ConstProp +- // MIR for `unreachable_ref` before GVN ++ // MIR for `unreachable_ref` after GVN fn unreachable_ref() -> ! { let mut _0: !; diff --git a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.64bit.diff similarity index 77% rename from tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff rename to tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.64bit.diff index b684ba34c69..430d16c97a6 100644 --- a/tests/mir-opt/const_prop/transmute.unreachable_ref.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.unreachable_ref.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `unreachable_ref` before ConstProp -+ // MIR for `unreachable_ref` after ConstProp +- // MIR for `unreachable_ref` before GVN ++ // MIR for `unreachable_ref` after GVN fn unreachable_ref() -> ! { let mut _0: !; diff --git a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.32bit.diff b/tests/mir-opt/const_prop/transmute.valid_char.GVN.32bit.diff similarity index 70% rename from tests/mir-opt/const_prop/transmute.valid_char.ConstProp.32bit.diff rename to tests/mir-opt/const_prop/transmute.valid_char.GVN.32bit.diff index f215b3ca398..f9d002f96ab 100644 --- a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.32bit.diff +++ b/tests/mir-opt/const_prop/transmute.valid_char.GVN.32bit.diff @@ -1,5 +1,5 @@ -- // MIR for `valid_char` before ConstProp -+ // MIR for `valid_char` after ConstProp +- // MIR for `valid_char` before GVN ++ // MIR for `valid_char` after GVN fn valid_char() -> char { let mut _0: char; diff --git a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.64bit.diff b/tests/mir-opt/const_prop/transmute.valid_char.GVN.64bit.diff similarity index 70% rename from tests/mir-opt/const_prop/transmute.valid_char.ConstProp.64bit.diff rename to tests/mir-opt/const_prop/transmute.valid_char.GVN.64bit.diff index f215b3ca398..f9d002f96ab 100644 --- a/tests/mir-opt/const_prop/transmute.valid_char.ConstProp.64bit.diff +++ b/tests/mir-opt/const_prop/transmute.valid_char.GVN.64bit.diff @@ -1,5 +1,5 @@ -- // MIR for `valid_char` before ConstProp -+ // MIR for `valid_char` after ConstProp +- // MIR for `valid_char` before GVN ++ // MIR for `valid_char` after GVN fn valid_char() -> char { let mut _0: char; diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff similarity index 69% rename from tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff rename to tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff index f19650d5a83..c2f3fb1b3b5 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -11,8 +11,9 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); - _1 = (const 1_u32, const 2_u32); ++ nop; + _1 = const (1_u32, 2_u32); StorageLive(_2); StorageLive(_3); @@ -26,20 +27,13 @@ StorageDead(_3); StorageDead(_2); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } + } + + ALLOC0 (size: 8, align: 4) { -+ 01 00 00 00 02 00 00 00 │ ........ -+ } -+ -+ ALLOC1 (size: 8, align: 4) { -+ 01 00 00 00 02 00 00 00 │ ........ -+ } -+ -+ ALLOC2 (size: 8, align: 4) { + 01 00 00 00 02 00 00 00 │ ........ } diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff similarity index 69% rename from tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff rename to tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff index 67307c42331..55d9a3b0cac 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.main.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.main.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -11,8 +11,9 @@ } bb0: { - StorageLive(_1); +- StorageLive(_1); - _1 = (const 1_u32, const 2_u32); ++ nop; + _1 = const (1_u32, 2_u32); StorageLive(_2); StorageLive(_3); @@ -26,20 +27,13 @@ StorageDead(_3); StorageDead(_2); _0 = const (); - StorageDead(_1); +- StorageDead(_1); ++ nop; return; } + } + + ALLOC0 (size: 8, align: 4) { -+ 01 00 00 00 02 00 00 00 │ ........ -+ } -+ -+ ALLOC1 (size: 8, align: 4) { -+ 01 00 00 00 02 00 00 00 │ ........ -+ } -+ -+ ALLOC2 (size: 8, align: 4) { + 01 00 00 00 02 00 00 00 │ ........ } diff --git a/tests/mir-opt/const_prop/tuple_literal_propagation.rs b/tests/mir-opt/const_prop/tuple_literal_propagation.rs index dfc4a6f3fbb..6803612f0a5 100644 --- a/tests/mir-opt/const_prop/tuple_literal_propagation.rs +++ b/tests/mir-opt/const_prop/tuple_literal_propagation.rs @@ -1,6 +1,6 @@ -// unit-test: ConstProp +// unit-test: GVN // EMIT_MIR_FOR_EACH_PANIC_STRATEGY -// EMIT_MIR tuple_literal_propagation.main.ConstProp.diff +// EMIT_MIR tuple_literal_propagation.main.GVN.diff fn main() { // CHECK-LABEL: fn main( diff --git a/tests/mir-opt/const_prop/while_let_loops.change_loop_body.ConstProp.diff b/tests/mir-opt/const_prop/while_let_loops.change_loop_body.GVN.diff similarity index 68% rename from tests/mir-opt/const_prop/while_let_loops.change_loop_body.ConstProp.diff rename to tests/mir-opt/const_prop/while_let_loops.change_loop_body.GVN.diff index f54908b4a38..9548afc9d40 100644 --- a/tests/mir-opt/const_prop/while_let_loops.change_loop_body.ConstProp.diff +++ b/tests/mir-opt/const_prop/while_let_loops.change_loop_body.GVN.diff @@ -1,5 +1,5 @@ -- // MIR for `change_loop_body` before ConstProp -+ // MIR for `change_loop_body` after ConstProp +- // MIR for `change_loop_body` before GVN ++ // MIR for `change_loop_body` after GVN fn change_loop_body() -> () { let mut _0: (); @@ -21,15 +21,17 @@ StorageLive(_1); _1 = const 0_i32; StorageLive(_3); - _3 = Option::::None; +- _3 = Option::::None; - _4 = discriminant(_3); - switchInt(move _4) -> [1: bb1, otherwise: bb3]; ++ _3 = const Option::::None; + _4 = const 0_isize; + switchInt(const 0_isize) -> [1: bb1, otherwise: bb3]; } bb1: { - switchInt(((_3 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; +- switchInt(((_3 as Some).0: u32)) -> [0: bb2, otherwise: bb3]; ++ switchInt(const Indirect { alloc_id: ALLOC0, offset: Size(4 bytes) }: u32) -> [0: bb2, otherwise: bb3]; } bb2: { @@ -50,5 +52,9 @@ StorageDead(_1); return; } ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 00 00 00 00 __ __ __ __ │ ....░░░░ } diff --git a/tests/mir-opt/const_prop/while_let_loops.rs b/tests/mir-opt/const_prop/while_let_loops.rs index 8b2a73438d6..d6527552bb0 100644 --- a/tests/mir-opt/const_prop/while_let_loops.rs +++ b/tests/mir-opt/const_prop/while_let_loops.rs @@ -1,5 +1,5 @@ -// unit-test: ConstProp -// EMIT_MIR while_let_loops.change_loop_body.ConstProp.diff +// unit-test: GVN +// EMIT_MIR while_let_loops.change_loop_body.GVN.diff pub fn change_loop_body() { // CHECK-LABEL: fn change_loop_body( diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff index ddfe2e8c831..6925fdb1e70 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff @@ -74,18 +74,18 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); - _8 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); - _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); - _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); - _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; @@ -97,15 +97,3 @@ } } - ALLOC2 (size: 8, align: 4) { - 01 00 00 00 00 00 00 00 │ ........ - } - - ALLOC1 (size: 8, align: 4) { - 01 00 00 00 00 00 00 00 │ ........ - } - - ALLOC0 (size: 8, align: 4) { - 01 00 00 00 00 00 00 00 │ ........ - } - diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff index 861295faa5a..82ad842505c 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff @@ -74,18 +74,18 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); - _8 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); - _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); - _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); - _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; @@ -101,15 +101,3 @@ } } - ALLOC2 (size: 8, align: 4) { - 01 00 00 00 00 00 00 00 │ ........ - } - - ALLOC1 (size: 8, align: 4) { - 01 00 00 00 00 00 00 00 │ ........ - } - - ALLOC0 (size: 8, align: 4) { - 01 00 00 00 00 00 00 00 │ ........ - } - diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff index cbb639edc53..6925fdb1e70 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff @@ -74,18 +74,18 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); - _8 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); - _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); - _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); - _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; @@ -97,15 +97,3 @@ } } - ALLOC2 (size: 16, align: 8) { - 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - } - - ALLOC1 (size: 16, align: 8) { - 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - } - - ALLOC0 (size: 16, align: 8) { - 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - } - diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff index 656846e9f97..82ad842505c 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff @@ -74,18 +74,18 @@ StorageDead(_7); StorageLive(_8); StorageLive(_9); - _8 = const {0x1 as *const [bool; 0]}; - _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; + _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); - _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); - _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); - _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); - _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; @@ -101,15 +101,3 @@ } } - ALLOC2 (size: 16, align: 8) { - 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - } - - ALLOC1 (size: 16, align: 8) { - 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - } - - ALLOC0 (size: 16, align: 8) { - 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - } - diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff similarity index 70% rename from tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff rename to tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff index 8363783e64e..13545aa464a 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -77,23 +77,18 @@ StorageLive(_8); StorageLive(_9); - _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -- _5 = NonNull::<[bool; 0]> { pointer: _8 }; -+ _8 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; ++ _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); -- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); -- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); -- _2 = Box::<[bool]>(_3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); -- _1 = A { foo: move _2 }; -+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; @@ -103,17 +98,5 @@ StorageDead(_1); return; } -+ } -+ -+ ALLOC2 (size: 8, align: 4) { -+ 01 00 00 00 00 00 00 00 │ ........ -+ } -+ -+ ALLOC1 (size: 8, align: 4) { -+ 01 00 00 00 00 00 00 00 │ ........ -+ } -+ -+ ALLOC0 (size: 8, align: 4) { -+ 01 00 00 00 00 00 00 00 │ ........ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff similarity index 70% rename from tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff rename to tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff index 19326b6a933..bf326915381 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.32bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -77,23 +77,18 @@ StorageLive(_8); StorageLive(_9); - _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -- _5 = NonNull::<[bool; 0]> { pointer: _8 }; -+ _8 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; ++ _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); -- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); -- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); -- _2 = Box::<[bool]>(_3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); -- _1 = A { foo: move _2 }; -+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; @@ -107,17 +102,5 @@ bb2 (cleanup): { resume; } -+ } -+ -+ ALLOC2 (size: 8, align: 4) { -+ 01 00 00 00 00 00 00 00 │ ........ -+ } -+ -+ ALLOC1 (size: 8, align: 4) { -+ 01 00 00 00 00 00 00 00 │ ........ -+ } -+ -+ ALLOC0 (size: 8, align: 4) { -+ 01 00 00 00 00 00 00 00 │ ........ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff similarity index 69% rename from tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff rename to tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff index 0d1e2430ce3..13545aa464a 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-abort.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -77,23 +77,18 @@ StorageLive(_8); StorageLive(_9); - _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -- _5 = NonNull::<[bool; 0]> { pointer: _8 }; -+ _8 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; ++ _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); -- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); -- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); -- _2 = Box::<[bool]>(_3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); -- _1 = A { foo: move _2 }; -+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind unreachable]; @@ -103,17 +98,5 @@ StorageDead(_1); return; } -+ } -+ -+ ALLOC2 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ -+ } -+ -+ ALLOC1 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ -+ } -+ -+ ALLOC0 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff similarity index 70% rename from tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff rename to tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff index 35f1e5ba796..bf326915381 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.main.GVN.64bit.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); @@ -77,23 +77,18 @@ StorageLive(_8); StorageLive(_9); - _8 = _6 as *const [bool; 0] (PointerCoercion(MutToConstPointer)); -- _5 = NonNull::<[bool; 0]> { pointer: _8 }; -+ _8 = const {0x1 as *const [bool; 0]}; -+ _5 = const NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}; ++ _8 = const {0x1 as *mut [bool; 0]} as *const [bool; 0] (PointerCoercion(MutToConstPointer)); + _5 = NonNull::<[bool; 0]> { pointer: _8 }; StorageDead(_9); StorageDead(_8); StorageDead(_6); -- _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; -+ _4 = const Unique::<[bool; 0]> {{ pointer: NonNull::<[bool; 0]> {{ pointer: {0x1 as *const [bool; 0]} }}, _marker: PhantomData::<[bool; 0]> }}; + _4 = Unique::<[bool; 0]> { pointer: move _5, _marker: const PhantomData::<[bool; 0]> }; StorageDead(_5); -- _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); -+ _3 = const Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC0, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}; + _3 = move _4 as std::ptr::Unique<[bool]> (PointerCoercion(Unsize)); StorageDead(_4); -- _2 = Box::<[bool]>(_3, const std::alloc::Global); -+ _2 = const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC1, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global); + _2 = Box::<[bool]>(_3, const std::alloc::Global); StorageDead(_3); -- _1 = A { foo: move _2 }; -+ _1 = A { foo: const Box::<[bool]>(Unique::<[bool]> {{ pointer: NonNull::<[bool]> {{ pointer: Indirect { alloc_id: ALLOC2, offset: Size(0 bytes) }: *const [bool] }}, _marker: PhantomData::<[bool]> }}, std::alloc::Global) }; + _1 = A { foo: move _2 }; StorageDead(_2); _0 = const (); drop(_1) -> [return: bb1, unwind: bb2]; @@ -107,17 +102,5 @@ bb2 (cleanup): { resume; } -+ } -+ -+ ALLOC2 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ -+ } -+ -+ ALLOC1 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ -+ } -+ -+ ALLOC0 (size: 16, align: 8) { -+ 01 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ } diff --git a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs index 1bb052736c0..8006bd510e1 100644 --- a/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs +++ b/tests/mir-opt/dataflow-const-prop/default_boxed_slice.rs @@ -1,6 +1,6 @@ // skip-filecheck // unit-test: DataflowConstProp -// compile-flags: -Zmir-enable-passes=+ConstProp,+Inline +// compile-flags: -Zmir-enable-passes=+GVN,+Inline // ignore-debug assertions change the output MIR // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR_FOR_EACH_PANIC_STRATEGY @@ -9,7 +9,7 @@ struct A { foo: Box<[bool]>, } -// EMIT_MIR default_boxed_slice.main.ConstProp.diff +// EMIT_MIR default_boxed_slice.main.GVN.diff // EMIT_MIR default_boxed_slice.main.DataflowConstProp.diff fn main() { // ConstProp will create a constant of type `Box<[bool]>`. diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff index 142e08f4d6c..993e0f1d1a6 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-abort.diff @@ -4,12 +4,13 @@ fn main() -> () { let mut _0: (); let _1: main::Un; + let mut _2: u32; scope 1 { debug un => _1; scope 2 { } scope 4 (inlined std::mem::drop::) { - debug _x => const 1_u32; + debug _x => _2; } } scope 3 (inlined val) { @@ -18,6 +19,9 @@ bb0: { StorageLive(_1); _1 = Un { us: const 1_u32 }; + StorageLive(_2); + _2 = (_1.0: u32); + StorageDead(_2); StorageDead(_1); return; } diff --git a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff index 142e08f4d6c..993e0f1d1a6 100644 --- a/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/union.main.DestinationPropagation.panic-unwind.diff @@ -4,12 +4,13 @@ fn main() -> () { let mut _0: (); let _1: main::Un; + let mut _2: u32; scope 1 { debug un => _1; scope 2 { } scope 4 (inlined std::mem::drop::) { - debug _x => const 1_u32; + debug _x => _2; } } scope 3 (inlined val) { @@ -18,6 +19,9 @@ bb0: { StorageLive(_1); _1 = Un { us: const 1_u32 }; + StorageLive(_2); + _2 = (_1.0: u32); + StorageDead(_2); StorageDead(_1); return; } diff --git a/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-abort.diff b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-abort.diff index 97ca825092e..80b5681ad06 100644 --- a/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-abort.diff +++ b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-abort.diff @@ -33,8 +33,8 @@ - StorageLive(_5); - _5 = _1; - StorageLive(_6); -- _6 = _2; -- _4 = g::(move _5, move _6) -> [return: bb2, unwind unreachable]; +- _6 = _1; +- _4 = g::(_1, _1) -> [return: bb2, unwind unreachable]; - } - - bb2: { @@ -48,20 +48,22 @@ - bb3: { StorageLive(_7); - StorageLive(_8); -- _8 = _2; +- _8 = _1; +- StorageLive(_9); +- _9 = _1; +- _7 = g::(_1, _1) -> [return: bb4, unwind unreachable]; + nop; + nop; - StorageLive(_9); -- _9 = _2; -- _7 = g::(move _8, move _9) -> [return: bb4, unwind unreachable]; -+ _9 = _1; -+ _7 = g::(move _1, move _9) -> [return: bb2, unwind unreachable]; ++ nop; ++ nop; ++ _7 = g::(_1, _1) -> [return: bb2, unwind unreachable]; } - bb4: { -+ bb2: { - StorageDead(_9); +- StorageDead(_9); - StorageDead(_8); ++ bb2: { ++ nop; + nop; StorageDead(_7); _0 = const (); diff --git a/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-unwind.diff index 7f730a77b06..eae7dd17b48 100644 --- a/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/unreachable.f.DestinationPropagation.panic-unwind.diff @@ -33,8 +33,8 @@ - StorageLive(_5); - _5 = _1; - StorageLive(_6); -- _6 = _2; -- _4 = g::(move _5, move _6) -> [return: bb2, unwind continue]; +- _6 = _1; +- _4 = g::(_1, _1) -> [return: bb2, unwind continue]; - } - - bb2: { @@ -48,20 +48,22 @@ - bb3: { StorageLive(_7); - StorageLive(_8); -- _8 = _2; +- _8 = _1; +- StorageLive(_9); +- _9 = _1; +- _7 = g::(_1, _1) -> [return: bb4, unwind continue]; + nop; + nop; - StorageLive(_9); -- _9 = _2; -- _7 = g::(move _8, move _9) -> [return: bb4, unwind continue]; -+ _9 = _1; -+ _7 = g::(move _1, move _9) -> [return: bb2, unwind continue]; ++ nop; ++ nop; ++ _7 = g::(_1, _1) -> [return: bb2, unwind continue]; } - bb4: { -+ bb2: { - StorageDead(_9); +- StorageDead(_9); - StorageDead(_8); ++ bb2: { ++ nop; + nop; StorageDead(_7); _0 = const (); diff --git a/tests/mir-opt/dest-prop/unreachable.rs b/tests/mir-opt/dest-prop/unreachable.rs index a47d2a0c8e2..0bde157ff61 100644 --- a/tests/mir-opt/dest-prop/unreachable.rs +++ b/tests/mir-opt/dest-prop/unreachable.rs @@ -4,7 +4,7 @@ // Regression test for issue #105428. // // compile-flags: --crate-type=lib -Zmir-opt-level=0 -// compile-flags: -Zmir-enable-passes=+ConstProp,+SimplifyConstCondition-after-const-prop,+DestinationPropagation +// compile-flags: -Zmir-enable-passes=+GVN,+SimplifyConstCondition-after-const-prop,+DestinationPropagation // EMIT_MIR unreachable.f.DestinationPropagation.diff pub fn f(a: T) { diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff similarity index 61% rename from tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff rename to tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff index 594609fade9..0ba1bac0a03 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-unwind.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-abort.diff @@ -1,5 +1,5 @@ -- // MIR for `float_to_exponential_common` before ConstProp -+ // MIR for `float_to_exponential_common` after ConstProp +- // MIR for `float_to_exponential_common` before GVN ++ // MIR for `float_to_exponential_common` after GVN fn float_to_exponential_common(_1: &mut Formatter<'_>, _2: &T, _3: bool) -> Result<(), std::fmt::Error> { debug fmt => _1; @@ -9,10 +9,17 @@ let _4: bool; let mut _6: std::option::Option; let mut _7: isize; - let mut _9: core::num::flt2dec::Sign; - let mut _10: u32; - let mut _11: u32; - let mut _12: core::num::flt2dec::Sign; + let mut _9: &mut std::fmt::Formatter<'_>; + let mut _10: &T; + let mut _11: core::num::flt2dec::Sign; + let mut _12: u32; + let mut _13: u32; + let mut _14: usize; + let mut _15: bool; + let mut _16: &mut std::fmt::Formatter<'_>; + let mut _17: &T; + let mut _18: core::num::flt2dec::Sign; + let mut _19: bool; scope 1 { debug force_sign => _4; let _5: core::num::flt2dec::Sign; @@ -29,30 +36,32 @@ } scope 4 (inlined Formatter::<'_>::sign_plus) { debug self => _1; - let mut _13: u32; - let mut _14: u32; + let mut _20: u32; + let mut _21: u32; } bb0: { StorageLive(_4); - StorageLive(_13); - StorageLive(_14); - _14 = ((*_1).0: u32); - _13 = BitAnd(move _14, const 1_u32); - StorageDead(_14); - _4 = Ne(move _13, const 0_u32); - StorageDead(_13); + StorageLive(_20); + StorageLive(_21); + _21 = ((*_1).0: u32); + _20 = BitAnd(move _21, const 1_u32); + StorageDead(_21); + _4 = Ne(move _20, const 0_u32); + StorageDead(_20); StorageLive(_5); switchInt(_4) -> [0: bb2, otherwise: bb1]; } bb1: { - _5 = const MinusPlus; +- _5 = MinusPlus; ++ _5 = const MinusPlus; goto -> bb3; } bb2: { - _5 = const Minus; +- _5 = Minus; ++ _5 = const Minus; goto -> bb3; } @@ -65,30 +74,30 @@ bb4: { _8 = ((_6 as Some).0: usize); - StorageLive(_9); - _9 = _5; - StorageLive(_10); StorageLive(_11); - _11 = _8 as u32 (IntToInt); - _10 = Add(move _11, const 1_u32); - StorageDead(_11); - _0 = float_to_exponential_common_exact::(_1, _2, move _9, move _10, _3) -> [return: bb5, unwind continue]; + _11 = _5; + StorageLive(_12); + StorageLive(_13); + _13 = _8 as u32 (IntToInt); + _12 = Add(move _13, const 1_u32); + StorageDead(_13); + _0 = float_to_exponential_common_exact::(_1, _2, move _11, move _12, _3) -> [return: bb5, unwind unreachable]; } bb5: { - StorageDead(_10); - StorageDead(_9); + StorageDead(_12); + StorageDead(_11); goto -> bb8; } bb6: { - StorageLive(_12); - _12 = _5; - _0 = float_to_exponential_common_shortest::(_1, _2, move _12, _3) -> [return: bb7, unwind continue]; + StorageLive(_18); + _18 = _5; + _0 = float_to_exponential_common_shortest::(_1, _2, move _18, _3) -> [return: bb7, unwind unreachable]; } bb7: { - StorageDead(_12); + StorageDead(_18); goto -> bb8; } diff --git a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-abort.diff b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff similarity index 61% rename from tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-abort.diff rename to tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff index 9d4bfcffcf0..27ea43ef12b 100644 --- a/tests/mir-opt/funky_arms.float_to_exponential_common.ConstProp.panic-abort.diff +++ b/tests/mir-opt/funky_arms.float_to_exponential_common.GVN.panic-unwind.diff @@ -1,5 +1,5 @@ -- // MIR for `float_to_exponential_common` before ConstProp -+ // MIR for `float_to_exponential_common` after ConstProp +- // MIR for `float_to_exponential_common` before GVN ++ // MIR for `float_to_exponential_common` after GVN fn float_to_exponential_common(_1: &mut Formatter<'_>, _2: &T, _3: bool) -> Result<(), std::fmt::Error> { debug fmt => _1; @@ -9,10 +9,17 @@ let _4: bool; let mut _6: std::option::Option; let mut _7: isize; - let mut _9: core::num::flt2dec::Sign; - let mut _10: u32; - let mut _11: u32; - let mut _12: core::num::flt2dec::Sign; + let mut _9: &mut std::fmt::Formatter<'_>; + let mut _10: &T; + let mut _11: core::num::flt2dec::Sign; + let mut _12: u32; + let mut _13: u32; + let mut _14: usize; + let mut _15: bool; + let mut _16: &mut std::fmt::Formatter<'_>; + let mut _17: &T; + let mut _18: core::num::flt2dec::Sign; + let mut _19: bool; scope 1 { debug force_sign => _4; let _5: core::num::flt2dec::Sign; @@ -29,30 +36,32 @@ } scope 4 (inlined Formatter::<'_>::sign_plus) { debug self => _1; - let mut _13: u32; - let mut _14: u32; + let mut _20: u32; + let mut _21: u32; } bb0: { StorageLive(_4); - StorageLive(_13); - StorageLive(_14); - _14 = ((*_1).0: u32); - _13 = BitAnd(move _14, const 1_u32); - StorageDead(_14); - _4 = Ne(move _13, const 0_u32); - StorageDead(_13); + StorageLive(_20); + StorageLive(_21); + _21 = ((*_1).0: u32); + _20 = BitAnd(move _21, const 1_u32); + StorageDead(_21); + _4 = Ne(move _20, const 0_u32); + StorageDead(_20); StorageLive(_5); switchInt(_4) -> [0: bb2, otherwise: bb1]; } bb1: { - _5 = const MinusPlus; +- _5 = MinusPlus; ++ _5 = const MinusPlus; goto -> bb3; } bb2: { - _5 = const Minus; +- _5 = Minus; ++ _5 = const Minus; goto -> bb3; } @@ -65,30 +74,30 @@ bb4: { _8 = ((_6 as Some).0: usize); - StorageLive(_9); - _9 = _5; - StorageLive(_10); StorageLive(_11); - _11 = _8 as u32 (IntToInt); - _10 = Add(move _11, const 1_u32); - StorageDead(_11); - _0 = float_to_exponential_common_exact::(_1, _2, move _9, move _10, _3) -> [return: bb5, unwind unreachable]; + _11 = _5; + StorageLive(_12); + StorageLive(_13); + _13 = _8 as u32 (IntToInt); + _12 = Add(move _13, const 1_u32); + StorageDead(_13); + _0 = float_to_exponential_common_exact::(_1, _2, move _11, move _12, _3) -> [return: bb5, unwind continue]; } bb5: { - StorageDead(_10); - StorageDead(_9); + StorageDead(_12); + StorageDead(_11); goto -> bb8; } bb6: { - StorageLive(_12); - _12 = _5; - _0 = float_to_exponential_common_shortest::(_1, _2, move _12, _3) -> [return: bb7, unwind unreachable]; + StorageLive(_18); + _18 = _5; + _0 = float_to_exponential_common_shortest::(_1, _2, move _18, _3) -> [return: bb7, unwind continue]; } bb7: { - StorageDead(_12); + StorageDead(_18); goto -> bb8; } diff --git a/tests/mir-opt/funky_arms.rs b/tests/mir-opt/funky_arms.rs index 14aad039946..eae158f9f77 100644 --- a/tests/mir-opt/funky_arms.rs +++ b/tests/mir-opt/funky_arms.rs @@ -9,7 +9,7 @@ extern crate core; use core::num::flt2dec; use std::fmt::{Formatter, Result}; -// EMIT_MIR funky_arms.float_to_exponential_common.ConstProp.diff +// EMIT_MIR funky_arms.float_to_exponential_common.GVN.diff pub fn float_to_exponential_common(fmt: &mut Formatter<'_>, num: &T, upper: bool) -> Result where T: flt2dec::DecodableFloat, diff --git a/tests/mir-opt/issue_101973.inner.ConstProp.panic-abort.diff b/tests/mir-opt/issue_101973.inner.ConstProp.panic-abort.diff deleted file mode 100644 index d082e9d31dc..00000000000 --- a/tests/mir-opt/issue_101973.inner.ConstProp.panic-abort.diff +++ /dev/null @@ -1,67 +0,0 @@ -- // MIR for `inner` before ConstProp -+ // MIR for `inner` after ConstProp - - fn inner(_1: u32) -> i64 { - debug fields => _1; - let mut _0: i64; - let mut _2: i32; - let mut _3: u32; - let mut _4: u32; - let mut _5: u32; - let mut _6: u32; - let mut _7: u32; - scope 1 (inlined imm8) { - debug x => _1; - let mut _8: u32; - let mut _9: u32; - scope 2 { - debug out => _4; - } - } - scope 3 (inlined core::num::::rotate_right) { - debug self => _4; - debug n => _5; - } - - bb0: { - StorageLive(_2); - StorageLive(_3); - StorageLive(_4); - _4 = const 0_u32; - StorageLive(_9); - StorageLive(_8); - _8 = Shr(_1, const 0_i32); - _9 = BitAnd(move _8, const 255_u32); - StorageDead(_8); - _4 = BitOr(const 0_u32, move _9); - StorageDead(_9); - StorageLive(_5); - StorageLive(_6); - StorageLive(_7); - assert(const true, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> [success: bb1, unwind unreachable]; - } - - bb1: { - _7 = Shr(_1, const 8_i32); - _6 = BitAnd(move _7, const 15_u32); - StorageDead(_7); - assert(const true, "attempt to shift left by `{}`, which would overflow", const 1_i32) -> [success: bb2, unwind unreachable]; - } - - bb2: { - _5 = Shl(move _6, const 1_i32); - StorageDead(_6); - _3 = rotate_right::(move _4, move _5) -> [return: bb3, unwind unreachable]; - } - - bb3: { - StorageDead(_5); - StorageDead(_4); - _2 = move _3 as i32 (IntToInt); - StorageDead(_3); - _0 = move _2 as i64 (IntToInt); - StorageDead(_2); - return; - } - } - diff --git a/tests/mir-opt/issue_101973.inner.ConstProp.panic-unwind.diff b/tests/mir-opt/issue_101973.inner.ConstProp.panic-unwind.diff deleted file mode 100644 index 0962a449f73..00000000000 --- a/tests/mir-opt/issue_101973.inner.ConstProp.panic-unwind.diff +++ /dev/null @@ -1,67 +0,0 @@ -- // MIR for `inner` before ConstProp -+ // MIR for `inner` after ConstProp - - fn inner(_1: u32) -> i64 { - debug fields => _1; - let mut _0: i64; - let mut _2: i32; - let mut _3: u32; - let mut _4: u32; - let mut _5: u32; - let mut _6: u32; - let mut _7: u32; - scope 1 (inlined imm8) { - debug x => _1; - let mut _8: u32; - let mut _9: u32; - scope 2 { - debug out => _4; - } - } - scope 3 (inlined core::num::::rotate_right) { - debug self => _4; - debug n => _5; - } - - bb0: { - StorageLive(_2); - StorageLive(_3); - StorageLive(_4); - _4 = const 0_u32; - StorageLive(_9); - StorageLive(_8); - _8 = Shr(_1, const 0_i32); - _9 = BitAnd(move _8, const 255_u32); - StorageDead(_8); - _4 = BitOr(const 0_u32, move _9); - StorageDead(_9); - StorageLive(_5); - StorageLive(_6); - StorageLive(_7); - assert(const true, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> [success: bb1, unwind continue]; - } - - bb1: { - _7 = Shr(_1, const 8_i32); - _6 = BitAnd(move _7, const 15_u32); - StorageDead(_7); - assert(const true, "attempt to shift left by `{}`, which would overflow", const 1_i32) -> [success: bb2, unwind continue]; - } - - bb2: { - _5 = Shl(move _6, const 1_i32); - StorageDead(_6); - _3 = rotate_right::(move _4, move _5) -> [return: bb3, unwind unreachable]; - } - - bb3: { - StorageDead(_5); - StorageDead(_4); - _2 = move _3 as i32 (IntToInt); - StorageDead(_3); - _0 = move _2 as i64 (IntToInt); - StorageDead(_2); - return; - } - } - diff --git a/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff b/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff new file mode 100644 index 00000000000..d2db8f61916 --- /dev/null +++ b/tests/mir-opt/issue_101973.inner.GVN.panic-abort.diff @@ -0,0 +1,83 @@ +- // MIR for `inner` before GVN ++ // MIR for `inner` after GVN + + fn inner(_1: u32) -> i64 { + debug fields => _1; + let mut _0: i64; + let mut _2: i32; + let mut _3: u32; + let mut _4: u32; + let mut _5: u32; + let mut _6: u32; + let mut _7: u32; + let mut _8: u32; + let mut _9: u32; + let mut _10: u32; + let mut _11: bool; + let mut _12: u32; + let mut _13: bool; + scope 1 (inlined imm8) { + debug x => _1; + let mut _14: u32; + let mut _15: u32; + scope 2 { + debug out => _4; + } + } + scope 3 (inlined core::num::::rotate_right) { + debug self => _4; + debug n => _6; + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _4 = const 0_u32; + StorageLive(_15); + StorageLive(_14); + _14 = Shr(_1, const 0_i32); + _15 = BitAnd(move _14, const 255_u32); + StorageDead(_14); + _4 = BitOr(const 0_u32, move _15); + StorageDead(_15); + StorageLive(_6); + StorageLive(_7); + StorageLive(_8); +- _10 = const 8_i32 as u32 (IntToInt); +- _11 = Lt(move _10, const 32_u32); +- assert(move _11, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> [success: bb1, unwind unreachable]; ++ _10 = const 8_u32; ++ _11 = const true; ++ assert(const true, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> [success: bb1, unwind unreachable]; + } + + bb1: { + _8 = Shr(_1, const 8_i32); + _7 = BitAnd(move _8, const 15_u32); + StorageDead(_8); +- _12 = const 1_i32 as u32 (IntToInt); +- _13 = Lt(move _12, const 32_u32); +- assert(move _13, "attempt to shift left by `{}`, which would overflow", const 1_i32) -> [success: bb2, unwind unreachable]; ++ _12 = const 1_u32; ++ _13 = const true; ++ assert(const true, "attempt to shift left by `{}`, which would overflow", const 1_i32) -> [success: bb2, unwind unreachable]; + } + + bb2: { + _6 = Shl(move _7, const 1_i32); + StorageDead(_7); + _3 = rotate_right::(move _4, move _6) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_6); + StorageDead(_4); + _2 = move _3 as i32 (IntToInt); + StorageDead(_3); + _0 = move _2 as i64 (IntToInt); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff b/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff new file mode 100644 index 00000000000..514183b3bc0 --- /dev/null +++ b/tests/mir-opt/issue_101973.inner.GVN.panic-unwind.diff @@ -0,0 +1,83 @@ +- // MIR for `inner` before GVN ++ // MIR for `inner` after GVN + + fn inner(_1: u32) -> i64 { + debug fields => _1; + let mut _0: i64; + let mut _2: i32; + let mut _3: u32; + let mut _4: u32; + let mut _5: u32; + let mut _6: u32; + let mut _7: u32; + let mut _8: u32; + let mut _9: u32; + let mut _10: u32; + let mut _11: bool; + let mut _12: u32; + let mut _13: bool; + scope 1 (inlined imm8) { + debug x => _1; + let mut _14: u32; + let mut _15: u32; + scope 2 { + debug out => _4; + } + } + scope 3 (inlined core::num::::rotate_right) { + debug self => _4; + debug n => _6; + } + + bb0: { + StorageLive(_2); + StorageLive(_3); + StorageLive(_4); + _4 = const 0_u32; + StorageLive(_15); + StorageLive(_14); + _14 = Shr(_1, const 0_i32); + _15 = BitAnd(move _14, const 255_u32); + StorageDead(_14); + _4 = BitOr(const 0_u32, move _15); + StorageDead(_15); + StorageLive(_6); + StorageLive(_7); + StorageLive(_8); +- _10 = const 8_i32 as u32 (IntToInt); +- _11 = Lt(move _10, const 32_u32); +- assert(move _11, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> [success: bb1, unwind continue]; ++ _10 = const 8_u32; ++ _11 = const true; ++ assert(const true, "attempt to shift right by `{}`, which would overflow", const 8_i32) -> [success: bb1, unwind continue]; + } + + bb1: { + _8 = Shr(_1, const 8_i32); + _7 = BitAnd(move _8, const 15_u32); + StorageDead(_8); +- _12 = const 1_i32 as u32 (IntToInt); +- _13 = Lt(move _12, const 32_u32); +- assert(move _13, "attempt to shift left by `{}`, which would overflow", const 1_i32) -> [success: bb2, unwind continue]; ++ _12 = const 1_u32; ++ _13 = const true; ++ assert(const true, "attempt to shift left by `{}`, which would overflow", const 1_i32) -> [success: bb2, unwind continue]; + } + + bb2: { + _6 = Shl(move _7, const 1_i32); + StorageDead(_7); + _3 = rotate_right::(move _4, move _6) -> [return: bb3, unwind unreachable]; + } + + bb3: { + StorageDead(_6); + StorageDead(_4); + _2 = move _3 as i32 (IntToInt); + StorageDead(_3); + _0 = move _2 as i64 (IntToInt); + StorageDead(_2); + return; + } + } + diff --git a/tests/mir-opt/issue_101973.rs b/tests/mir-opt/issue_101973.rs index 3de325bc170..83a4dfb20b5 100644 --- a/tests/mir-opt/issue_101973.rs +++ b/tests/mir-opt/issue_101973.rs @@ -1,7 +1,7 @@ // skip-filecheck // EMIT_MIR_FOR_EACH_PANIC_STRATEGY // compile-flags: -O -C debug-assertions=on -// This needs inlining followed by ConstProp to reproduce, so we cannot use "unit-test". +// This needs inlining followed by GVN to reproduce, so we cannot use "unit-test". #[inline] pub fn imm8(x: u32) -> u32 { @@ -10,7 +10,7 @@ pub fn imm8(x: u32) -> u32 { out } -// EMIT_MIR issue_101973.inner.ConstProp.diff +// EMIT_MIR issue_101973.inner.GVN.diff #[inline(never)] pub fn inner(fields: u32) -> i64 { imm8(fields).rotate_right(((fields >> 8) & 0xf) << 1) as i32 as i64 diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-abort.diff deleted file mode 100644 index 8c7ed678fe1..00000000000 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-abort.diff +++ /dev/null @@ -1,38 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); - let _1: i32; - let mut _3: u32; - scope 1 { - debug x => _1; - let _2: i32; - scope 2 { - debug y => _2; - scope 3 { - debug z => _3; - } - } - } - - bb0: { - StorageLive(_1); - assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable]; - } - - bb1: { - _1 = const 4_i32; - StorageLive(_2); - assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind unreachable]; - } - - bb2: { - _2 = const 3_i32; - _3 = const 42_u32; - StorageDead(_2); - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff deleted file mode 100644 index 5ba417a5b0f..00000000000 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.32bit.panic-unwind.diff +++ /dev/null @@ -1,38 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); - let _1: i32; - let mut _3: u32; - scope 1 { - debug x => _1; - let _2: i32; - scope 2 { - debug y => _2; - scope 3 { - debug z => _3; - } - } - } - - bb0: { - StorageLive(_1); - assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; - } - - bb1: { - _1 = const 4_i32; - StorageLive(_2); - assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind continue]; - } - - bb2: { - _2 = const 3_i32; - _3 = const 42_u32; - StorageDead(_2); - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-abort.diff deleted file mode 100644 index 8c7ed678fe1..00000000000 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-abort.diff +++ /dev/null @@ -1,38 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); - let _1: i32; - let mut _3: u32; - scope 1 { - debug x => _1; - let _2: i32; - scope 2 { - debug y => _2; - scope 3 { - debug z => _3; - } - } - } - - bb0: { - StorageLive(_1); - assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable]; - } - - bb1: { - _1 = const 4_i32; - StorageLive(_2); - assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind unreachable]; - } - - bb2: { - _2 = const 3_i32; - _3 = const 42_u32; - StorageDead(_2); - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff deleted file mode 100644 index 5ba417a5b0f..00000000000 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.ConstProp.64bit.panic-unwind.diff +++ /dev/null @@ -1,38 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); - let _1: i32; - let mut _3: u32; - scope 1 { - debug x => _1; - let _2: i32; - scope 2 { - debug y => _2; - scope 3 { - debug z => _3; - } - } - } - - bb0: { - StorageLive(_1); - assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; - } - - bb1: { - _1 = const 4_i32; - StorageLive(_2); - assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind continue]; - } - - bb2: { - _2 = const 3_i32; - _3 = const 42_u32; - StorageDead(_2); - StorageDead(_1); - return; - } - } - diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff new file mode 100644 index 00000000000..4e34233a979 --- /dev/null +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-abort.diff @@ -0,0 +1,63 @@ +- // MIR for `main` before GVN ++ // MIR for `main` after GVN + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _2: (i32, bool); + let mut _4: [i32; 6]; + let _5: usize; + let mut _6: usize; + let mut _7: bool; + let mut _9: u32; + scope 1 { + debug x => _1; + let _3: i32; + scope 2 { + debug y => _3; + let _8: u32; + scope 3 { + debug z => _9; + } + } + } + + bb0: { + StorageLive(_1); +- _2 = CheckedAdd(const 2_i32, const 2_i32); +- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable]; ++ _2 = const (4_i32, false); ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _1 = move (_2.0: i32); ++ _1 = const 4_i32; + StorageLive(_3); + StorageLive(_4); + _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; + StorageLive(_5); + _5 = const 3_usize; + _6 = const 6_usize; +- _7 = Lt(_5, _6); +- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind unreachable]; ++ _7 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind unreachable]; + } + + bb2: { +- _3 = _4[_5]; ++ _3 = const 3_i32; + StorageDead(_5); + StorageDead(_4); + _9 = const 42_u32; + StorageDead(_3); + StorageDead(_1); + return; + } ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 04 00 00 00 00 __ __ __ │ .....░░░ + } + diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff new file mode 100644 index 00000000000..275f17e52ae --- /dev/null +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.32bit.panic-unwind.diff @@ -0,0 +1,63 @@ +- // MIR for `main` before GVN ++ // MIR for `main` after GVN + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _2: (i32, bool); + let mut _4: [i32; 6]; + let _5: usize; + let mut _6: usize; + let mut _7: bool; + let mut _9: u32; + scope 1 { + debug x => _1; + let _3: i32; + scope 2 { + debug y => _3; + let _8: u32; + scope 3 { + debug z => _9; + } + } + } + + bb0: { + StorageLive(_1); +- _2 = CheckedAdd(const 2_i32, const 2_i32); +- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; ++ _2 = const (4_i32, false); ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; + } + + bb1: { +- _1 = move (_2.0: i32); ++ _1 = const 4_i32; + StorageLive(_3); + StorageLive(_4); + _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; + StorageLive(_5); + _5 = const 3_usize; + _6 = const 6_usize; +- _7 = Lt(_5, _6); +- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind continue]; ++ _7 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind continue]; + } + + bb2: { +- _3 = _4[_5]; ++ _3 = const 3_i32; + StorageDead(_5); + StorageDead(_4); + _9 = const 42_u32; + StorageDead(_3); + StorageDead(_1); + return; + } ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 04 00 00 00 00 __ __ __ │ .....░░░ + } + diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff new file mode 100644 index 00000000000..4e34233a979 --- /dev/null +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-abort.diff @@ -0,0 +1,63 @@ +- // MIR for `main` before GVN ++ // MIR for `main` after GVN + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _2: (i32, bool); + let mut _4: [i32; 6]; + let _5: usize; + let mut _6: usize; + let mut _7: bool; + let mut _9: u32; + scope 1 { + debug x => _1; + let _3: i32; + scope 2 { + debug y => _3; + let _8: u32; + scope 3 { + debug z => _9; + } + } + } + + bb0: { + StorageLive(_1); +- _2 = CheckedAdd(const 2_i32, const 2_i32); +- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable]; ++ _2 = const (4_i32, false); ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind unreachable]; + } + + bb1: { +- _1 = move (_2.0: i32); ++ _1 = const 4_i32; + StorageLive(_3); + StorageLive(_4); + _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; + StorageLive(_5); + _5 = const 3_usize; + _6 = const 6_usize; +- _7 = Lt(_5, _6); +- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind unreachable]; ++ _7 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind unreachable]; + } + + bb2: { +- _3 = _4[_5]; ++ _3 = const 3_i32; + StorageDead(_5); + StorageDead(_4); + _9 = const 42_u32; + StorageDead(_3); + StorageDead(_1); + return; + } ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 04 00 00 00 00 __ __ __ │ .....░░░ + } + diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff new file mode 100644 index 00000000000..275f17e52ae --- /dev/null +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.main.GVN.64bit.panic-unwind.diff @@ -0,0 +1,63 @@ +- // MIR for `main` before GVN ++ // MIR for `main` after GVN + + fn main() -> () { + let mut _0: (); + let _1: i32; + let mut _2: (i32, bool); + let mut _4: [i32; 6]; + let _5: usize; + let mut _6: usize; + let mut _7: bool; + let mut _9: u32; + scope 1 { + debug x => _1; + let _3: i32; + scope 2 { + debug y => _3; + let _8: u32; + scope 3 { + debug z => _9; + } + } + } + + bb0: { + StorageLive(_1); +- _2 = CheckedAdd(const 2_i32, const 2_i32); +- assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; ++ _2 = const (4_i32, false); ++ assert(!const false, "attempt to compute `{} + {}`, which would overflow", const 2_i32, const 2_i32) -> [success: bb1, unwind continue]; + } + + bb1: { +- _1 = move (_2.0: i32); ++ _1 = const 4_i32; + StorageLive(_3); + StorageLive(_4); + _4 = [const 0_i32, const 1_i32, const 2_i32, const 3_i32, const 4_i32, const 5_i32]; + StorageLive(_5); + _5 = const 3_usize; + _6 = const 6_usize; +- _7 = Lt(_5, _6); +- assert(move _7, "index out of bounds: the length is {} but the index is {}", move _6, _5) -> [success: bb2, unwind continue]; ++ _7 = const true; ++ assert(const true, "index out of bounds: the length is {} but the index is {}", const 6_usize, const 3_usize) -> [success: bb2, unwind continue]; + } + + bb2: { +- _3 = _4[_5]; ++ _3 = const 3_i32; + StorageDead(_5); + StorageDead(_4); + _9 = const 42_u32; + StorageDead(_3); + StorageDead(_1); + return; + } ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 04 00 00 00 00 __ __ __ │ .....░░░ + } + diff --git a/tests/mir-opt/pre-codegen/optimizes_into_variable.rs b/tests/mir-opt/pre-codegen/optimizes_into_variable.rs index bb089ea4455..fb634ca85ef 100644 --- a/tests/mir-opt/pre-codegen/optimizes_into_variable.rs +++ b/tests/mir-opt/pre-codegen/optimizes_into_variable.rs @@ -9,7 +9,7 @@ struct Point { // EMIT_MIR_FOR_EACH_BIT_WIDTH // EMIT_MIR optimizes_into_variable.main.ScalarReplacementOfAggregates.diff -// EMIT_MIR optimizes_into_variable.main.ConstProp.diff +// EMIT_MIR optimizes_into_variable.main.GVN.diff // EMIT_MIR optimizes_into_variable.main.SimplifyLocals-final.after.mir // EMIT_MIR optimizes_into_variable.main.PreCodegen.after.mir fn main() { diff --git a/tests/mir-opt/simplify_match.main.ConstProp.panic-unwind.diff b/tests/mir-opt/simplify_match.main.ConstProp.panic-unwind.diff deleted file mode 100644 index 2d60e234e06..00000000000 --- a/tests/mir-opt/simplify_match.main.ConstProp.panic-unwind.diff +++ /dev/null @@ -1,28 +0,0 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp - - fn main() -> () { - let mut _0: (); - let _1: bool; - scope 1 { - debug x => _1; - } - - bb0: { - _1 = const false; - switchInt(const false) -> [0: bb1, otherwise: bb2]; - } - - bb1: { - goto -> bb3; - } - - bb2: { - _0 = noop() -> [return: bb3, unwind continue]; - } - - bb3: { - return; - } - } - diff --git a/tests/mir-opt/simplify_match.main.ConstProp.panic-abort.diff b/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff similarity index 50% rename from tests/mir-opt/simplify_match.main.ConstProp.panic-abort.diff rename to tests/mir-opt/simplify_match.main.GVN.panic-abort.diff index 2bb54d5a666..825babe7994 100644 --- a/tests/mir-opt/simplify_match.main.ConstProp.panic-abort.diff +++ b/tests/mir-opt/simplify_match.main.GVN.panic-abort.diff @@ -1,16 +1,18 @@ -- // MIR for `main` before ConstProp -+ // MIR for `main` after ConstProp +- // MIR for `main` before GVN ++ // MIR for `main` after GVN fn main() -> () { let mut _0: (); - let _1: bool; + let mut _1: bool; + let _2: bool; scope 1 { - debug x => _1; + debug x => _2; } bb0: { - _1 = const false; - switchInt(const false) -> [0: bb1, otherwise: bb2]; + _2 = const false; +- switchInt(_2) -> [0: bb1, otherwise: bb2]; ++ switchInt(const false) -> [0: bb1, otherwise: bb2]; } bb1: { diff --git a/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff b/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff new file mode 100644 index 00000000000..24ab6c39788 --- /dev/null +++ b/tests/mir-opt/simplify_match.main.GVN.panic-unwind.diff @@ -0,0 +1,30 @@ +- // MIR for `main` before GVN ++ // MIR for `main` after GVN + + fn main() -> () { + let mut _0: (); + let mut _1: bool; + let _2: bool; + scope 1 { + debug x => _2; + } + + bb0: { + _2 = const false; +- switchInt(_2) -> [0: bb1, otherwise: bb2]; ++ switchInt(const false) -> [0: bb1, otherwise: bb2]; + } + + bb1: { + goto -> bb3; + } + + bb2: { + _0 = noop() -> [return: bb3, unwind continue]; + } + + bb3: { + return; + } + } + diff --git a/tests/mir-opt/simplify_match.rs b/tests/mir-opt/simplify_match.rs index eb385005cd9..2eac93edbb8 100644 --- a/tests/mir-opt/simplify_match.rs +++ b/tests/mir-opt/simplify_match.rs @@ -3,7 +3,7 @@ #[inline(never)] fn noop() {} -// EMIT_MIR simplify_match.main.ConstProp.diff +// EMIT_MIR simplify_match.main.GVN.diff fn main() { match { let x = false; x } { true => noop(), diff --git a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr index f3ec3200f94..7e764ca7239 100644 --- a/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr +++ b/tests/ui/consts/const-eval/issue-50814-2.mir-opt.stderr @@ -10,12 +10,6 @@ note: erroneous constant encountered LL | & as Foo>::BAR | ^^^^^^^^^^^^^^^^^^^^^ -note: erroneous constant encountered - --> $DIR/issue-50814-2.rs:20:5 - | -LL | & as Foo>::BAR - | ^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0080`.