diff --git a/src/librustc_mir/transform/simplify.rs b/src/librustc_mir/transform/simplify.rs index c0da2c446d65f..da79a065eb797 100644 --- a/src/librustc_mir/transform/simplify.rs +++ b/src/librustc_mir/transform/simplify.rs @@ -368,21 +368,39 @@ impl<'a, 'tcx> Visitor<'tcx> for DeclMarker<'a, 'tcx> { if location.statement_index != block.statements.len() { let stmt = &block.statements[location.statement_index]; + fn can_skip_constant(c: &ty::Const<'tcx>) -> bool { + // Keep assignments from unevaluated constants around, since the + // evaluation may report errors, even if the use of the constant + // is dead code. + !matches!(c.val, ty::ConstKind::Unevaluated(..)) + } + + fn can_skip_operand(o: &Operand<'_>) -> bool { + match o { + Operand::Copy(p) | Operand::Move(p) => !p.is_indirect(), + Operand::Constant(c) => can_skip_constant(c.literal), + } + } + if let StatementKind::Assign(box (dest, rvalue)) = &stmt.kind { if !dest.is_indirect() && dest.local == *local { - if let Rvalue::Use(Operand::Constant(c)) = rvalue { - match c.literal.val { - // Keep assignments from unevaluated constants around, since the - // evaluation may report errors, even if the use of the constant - // is dead code. - ty::ConstKind::Unevaluated(..) => {} - _ => { - trace!("skipping store of const value {:?} to {:?}", c, dest); - return; - } + let can_skip = match rvalue { + Rvalue::Use(op) => can_skip_operand(op), + Rvalue::Discriminant(_) => true, + Rvalue::BinaryOp(_, l, r) | Rvalue::CheckedBinaryOp(_, l, r) => { + can_skip_operand(l) && can_skip_operand(r) } - } else if let Rvalue::Discriminant(d) = rvalue { - trace!("skipping store of discriminant value {:?} to {:?}", d, dest); + Rvalue::Repeat(op, c) => can_skip_operand(op) && can_skip_constant(c), + Rvalue::AddressOf(_, _) => true, + Rvalue::Len(_) => true, + Rvalue::UnaryOp(_, op) => can_skip_operand(op), + Rvalue::Aggregate(_, operands) => operands.iter().all(can_skip_operand), + + _ => false, + }; + + if can_skip { + trace!("skipping store of {:?} to {:?}", rvalue, dest); return; } } diff --git a/src/test/mir-opt/const_allocation3/32bit/rustc.main.ConstProp.after.mir b/src/test/mir-opt/const_allocation3/32bit/rustc.main.ConstProp.after.mir index 323134553c195..63e6b8358a534 100644 --- a/src/test/mir-opt/const_allocation3/32bit/rustc.main.ConstProp.after.mir +++ b/src/test/mir-opt/const_allocation3/32bit/rustc.main.ConstProp.after.mir @@ -30,30 +30,30 @@ fn main() -> () { } alloc0 (static: FOO, size: 4, align: 4) { - ╾alloc10+0╼ │ ╾──╼ + ╾alloc9+0─╼ │ ╾──╼ } -alloc10 (size: 168, align: 1) { +alloc9 (size: 168, align: 1) { 0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................ - 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾alloc5+0─╼ │ ............╾──╼ + 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾alloc4+0─╼ │ ............╾──╼ 0x20 │ 01 ef cd ab 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x30 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x40 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x50 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x60 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x70 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ - 0x80 │ 00 00 00 00 00 00 00 00 00 00 ╾alloc7+0─╼ 00 00 │ ..........╾──╼.. - 0x90 │ ╾alloc8+99╼ 00 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............ + 0x80 │ 00 00 00 00 00 00 00 00 00 00 ╾alloc6+0─╼ 00 00 │ ..........╾──╼.. + 0x90 │ ╾alloc7+99╼ 00 00 00 00 00 00 00 00 00 00 00 00 │ ╾──╼............ 0xa0 │ 00 00 00 00 00 00 00 00 │ ........ } -alloc5 (size: 4, align: 4) { +alloc4 (size: 4, align: 4) { 2a 00 00 00 │ *... } -alloc7 (fn: main) +alloc6 (fn: main) -alloc8 (size: 100, align: 1) { +alloc7 (size: 100, align: 1) { 0x00 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x20 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ diff --git a/src/test/mir-opt/const_allocation3/64bit/rustc.main.ConstProp.after.mir b/src/test/mir-opt/const_allocation3/64bit/rustc.main.ConstProp.after.mir index 952fe8336cd0e..7dea5c664d858 100644 --- a/src/test/mir-opt/const_allocation3/64bit/rustc.main.ConstProp.after.mir +++ b/src/test/mir-opt/const_allocation3/64bit/rustc.main.ConstProp.after.mir @@ -30,12 +30,12 @@ fn main() -> () { } alloc0 (static: FOO, size: 8, align: 8) { - ╾──────alloc10+0──────╼ │ ╾──────╼ + ╾──────alloc9+0───────╼ │ ╾──────╼ } -alloc10 (size: 180, align: 1) { +alloc9 (size: 180, align: 1) { 0x00 │ ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab ab │ ................ - 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾─alloc5+0─ │ ............╾─── + 0x10 │ ab ab ab ab ab ab ab ab ab ab ab ab ╾─alloc4+0─ │ ............╾─── 0x20 │ ──────────╼ 01 ef cd ab 00 00 00 00 00 00 00 00 │ ───╼............ 0x30 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x40 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ @@ -43,18 +43,18 @@ alloc10 (size: 180, align: 1) { 0x60 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x70 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x80 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ╾──── │ ..............╾─ - 0x90 │ ────alloc7+0────╼ 00 00 ╾──────alloc8+99──────╼ │ ─────╼..╾──────╼ + 0x90 │ ────alloc6+0────╼ 00 00 ╾──────alloc7+99──────╼ │ ─────╼..╾──────╼ 0xa0 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0xb0 │ 00 00 00 00 │ .... } -alloc5 (size: 4, align: 4) { +alloc4 (size: 4, align: 4) { 2a 00 00 00 │ *... } -alloc7 (fn: main) +alloc6 (fn: main) -alloc8 (size: 100, align: 1) { +alloc7 (size: 100, align: 1) { 0x00 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x10 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ 0x20 │ 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 │ ................ diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.SimplifyLocals.after.mir b/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.SimplifyLocals.after.mir index 5e2a8af060be8..f8aea27df6660 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.SimplifyLocals.after.mir +++ b/src/test/mir-opt/const_prop/optimizes_into_variable/32bit/rustc.main.SimplifyLocals.after.mir @@ -3,15 +3,14 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:11:11: 11:11 let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10 - let mut _3: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:31 scope 1 { debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10 let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10 scope 2 { debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10 - let _4: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 scope 3 { - debug z => _4; // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10 } } } @@ -26,70 +25,31 @@ fn main() -> () { // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } StorageLive(_2); // bb0[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10 - StorageLive(_3); // bb0[3]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31 - _3 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; // bb0[4]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31 - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000000)) - // mir::Constant - // + span: $DIR/optimizes_into_variable.rs:13:14: 13:15 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000001)) - // mir::Constant - // + span: $DIR/optimizes_into_variable.rs:13:17: 13:18 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000002)) - // mir::Constant - // + span: $DIR/optimizes_into_variable.rs:13:20: 13:21 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000003)) - // mir::Constant - // + span: $DIR/optimizes_into_variable.rs:13:23: 13:24 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000004)) - // mir::Constant - // + span: $DIR/optimizes_into_variable.rs:13:26: 13:27 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000005)) - // mir::Constant - // + span: $DIR/optimizes_into_variable.rs:13:29: 13:30 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } - _2 = const 3i32; // bb0[5]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 + _2 = const 3i32; // bb0[3]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000003)) // mir::Constant // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34 // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } - StorageDead(_3); // bb0[6]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35 - StorageLive(_4); // bb0[7]: scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 - _4 = const 42u32; // bb0[8]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 + StorageLive(_3); // bb0[4]: scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + _3 = const 42u32; // bb0[5]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 // ty::Const // + ty: u32 // + val: Value(Scalar(0x0000002a)) // mir::Constant // + span: $DIR/optimizes_into_variable.rs:14:13: 14:38 // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } - _0 = const (); // bb0[9]: scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2 + _0 = const (); // bb0[6]: scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2 // ty::Const // + ty: () // + val: Value(Scalar()) // mir::Constant // + span: $DIR/optimizes_into_variable.rs:11:11: 15:2 // + literal: Const { ty: (), val: Value(Scalar()) } - StorageDead(_4); // bb0[10]: scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2 - StorageDead(_2); // bb0[11]: scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2 - StorageDead(_1); // bb0[12]: scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2 - return; // bb0[13]: scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2 + StorageDead(_3); // bb0[7]: scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + StorageDead(_2); // bb0[8]: scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + StorageDead(_1); // bb0[9]: scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + return; // bb0[10]: scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2 } } diff --git a/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.SimplifyLocals.after.mir b/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.SimplifyLocals.after.mir index 5e2a8af060be8..f8aea27df6660 100644 --- a/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.SimplifyLocals.after.mir +++ b/src/test/mir-opt/const_prop/optimizes_into_variable/64bit/rustc.main.SimplifyLocals.after.mir @@ -3,15 +3,14 @@ fn main() -> () { let mut _0: (); // return place in scope 0 at $DIR/optimizes_into_variable.rs:11:11: 11:11 let _1: i32; // in scope 0 at $DIR/optimizes_into_variable.rs:12:9: 12:10 - let mut _3: [i32; 6]; // in scope 0 at $DIR/optimizes_into_variable.rs:13:13: 13:31 scope 1 { debug x => _1; // in scope 1 at $DIR/optimizes_into_variable.rs:12:9: 12:10 let _2: i32; // in scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10 scope 2 { debug y => _2; // in scope 2 at $DIR/optimizes_into_variable.rs:13:9: 13:10 - let _4: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + let _3: u32; // in scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 scope 3 { - debug z => _4; // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + debug z => _3; // in scope 3 at $DIR/optimizes_into_variable.rs:14:9: 14:10 } } } @@ -26,70 +25,31 @@ fn main() -> () { // + span: $DIR/optimizes_into_variable.rs:12:13: 12:18 // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } StorageLive(_2); // bb0[2]: scope 1 at $DIR/optimizes_into_variable.rs:13:9: 13:10 - StorageLive(_3); // bb0[3]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31 - _3 = [const 0i32, const 1i32, const 2i32, const 3i32, const 4i32, const 5i32]; // bb0[4]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:31 - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000000)) - // mir::Constant - // + span: $DIR/optimizes_into_variable.rs:13:14: 13:15 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000000)) } - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000001)) - // mir::Constant - // + span: $DIR/optimizes_into_variable.rs:13:17: 13:18 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000001)) } - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000002)) - // mir::Constant - // + span: $DIR/optimizes_into_variable.rs:13:20: 13:21 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000002)) } - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000003)) - // mir::Constant - // + span: $DIR/optimizes_into_variable.rs:13:23: 13:24 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000004)) - // mir::Constant - // + span: $DIR/optimizes_into_variable.rs:13:26: 13:27 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000004)) } - // ty::Const - // + ty: i32 - // + val: Value(Scalar(0x00000005)) - // mir::Constant - // + span: $DIR/optimizes_into_variable.rs:13:29: 13:30 - // + literal: Const { ty: i32, val: Value(Scalar(0x00000005)) } - _2 = const 3i32; // bb0[5]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 + _2 = const 3i32; // bb0[3]: scope 1 at $DIR/optimizes_into_variable.rs:13:13: 13:34 // ty::Const // + ty: i32 // + val: Value(Scalar(0x00000003)) // mir::Constant // + span: $DIR/optimizes_into_variable.rs:13:13: 13:34 // + literal: Const { ty: i32, val: Value(Scalar(0x00000003)) } - StorageDead(_3); // bb0[6]: scope 1 at $DIR/optimizes_into_variable.rs:13:34: 13:35 - StorageLive(_4); // bb0[7]: scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 - _4 = const 42u32; // bb0[8]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 + StorageLive(_3); // bb0[4]: scope 2 at $DIR/optimizes_into_variable.rs:14:9: 14:10 + _3 = const 42u32; // bb0[5]: scope 2 at $DIR/optimizes_into_variable.rs:14:13: 14:38 // ty::Const // + ty: u32 // + val: Value(Scalar(0x0000002a)) // mir::Constant // + span: $DIR/optimizes_into_variable.rs:14:13: 14:38 // + literal: Const { ty: u32, val: Value(Scalar(0x0000002a)) } - _0 = const (); // bb0[9]: scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2 + _0 = const (); // bb0[6]: scope 0 at $DIR/optimizes_into_variable.rs:11:11: 15:2 // ty::Const // + ty: () // + val: Value(Scalar()) // mir::Constant // + span: $DIR/optimizes_into_variable.rs:11:11: 15:2 // + literal: Const { ty: (), val: Value(Scalar()) } - StorageDead(_4); // bb0[10]: scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2 - StorageDead(_2); // bb0[11]: scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2 - StorageDead(_1); // bb0[12]: scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2 - return; // bb0[13]: scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2 + StorageDead(_3); // bb0[7]: scope 2 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + StorageDead(_2); // bb0[8]: scope 1 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + StorageDead(_1); // bb0[9]: scope 0 at $DIR/optimizes_into_variable.rs:15:1: 15:2 + return; // bb0[10]: scope 0 at $DIR/optimizes_into_variable.rs:15:2: 15:2 } } diff --git a/src/test/mir-opt/simplify-locals-fixedpoint/rustc.foo.SimplifyLocals.diff b/src/test/mir-opt/simplify-locals-fixedpoint/rustc.foo.SimplifyLocals.diff index 89326e8e3f675..bc59be48eee0f 100644 --- a/src/test/mir-opt/simplify-locals-fixedpoint/rustc.foo.SimplifyLocals.diff +++ b/src/test/mir-opt/simplify-locals-fixedpoint/rustc.foo.SimplifyLocals.diff @@ -26,40 +26,77 @@ StorageDead(_3); // bb0[7]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69 StorageDead(_2); // bb0[8]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:68: 4:69 _5 = discriminant((_1.0: std::option::Option)); // bb0[9]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20 - switchInt(move _5) -> [1isize: bb1, otherwise: bb3]; // bb0[10]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20 + switchInt(move _5) -> [1isize: bb2, otherwise: bb1]; // bb0[10]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:13: 4:20 } bb1: { - _4 = discriminant((_1.1: std::option::Option)); // bb1[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26 - switchInt(move _4) -> [0isize: bb2, otherwise: bb3]; // bb1[1]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26 + _0 = const (); // bb1[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6 + // ty::Const + // + ty: () + // + val: Value(Scalar()) + // mir::Constant + // + span: $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6 + // + literal: Const { ty: (), val: Value(Scalar()) } + goto -> bb7; // bb1[1]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6 } bb2: { - StorageLive(_6); // bb2[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19 - _6 = (((_1.0: std::option::Option) as Some).0: u8); // bb2[1]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19 - StorageLive(_7); // bb2[2]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 - StorageLive(_8); // bb2[3]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 - _8 = _6; // bb2[4]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 - _7 = Gt(move _8, const 42u8); // bb2[5]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 + _4 = discriminant((_1.1: std::option::Option)); // bb2[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26 + switchInt(move _4) -> [0isize: bb3, otherwise: bb1]; // bb2[1]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:22: 4:26 + } + + bb3: { + StorageLive(_6); // bb3[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19 + _6 = (((_1.0: std::option::Option) as Some).0: u8); // bb3[1]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:18: 4:19 + StorageLive(_7); // bb3[2]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 + StorageLive(_8); // bb3[3]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 + _8 = _6; // bb3[4]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:13 + _7 = Gt(move _8, const 42u8); // bb3[5]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:12: 5:20 // ty::Const // + ty: u8 // + val: Value(Scalar(0x2a)) // mir::Constant // + span: $DIR/simplify-locals-fixedpoint.rs:5:16: 5:20 // + literal: Const { ty: u8, val: Value(Scalar(0x2a)) } - StorageDead(_8); // bb2[6]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:19: 5:20 - StorageDead(_7); // bb2[7]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:8:5: 8:6 - StorageDead(_6); // bb2[8]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:8:5: 8:6 - goto -> bb3; // bb2[9]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6 + StorageDead(_8); // bb3[6]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:19: 5:20 + switchInt(_7) -> [false: bb4, otherwise: bb5]; // bb3[7]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 } - bb3: { - drop(_1) -> bb4; // bb3[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2 + bb4: { + _0 = const (); // bb4[0]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 + // ty::Const + // + ty: () + // + val: Value(Scalar()) + // mir::Constant + // + span: $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 + // + literal: Const { ty: (), val: Value(Scalar()) } + goto -> bb6; // bb4[1]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 } - bb4: { - StorageDead(_1); // bb4[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2 - return; // bb4[1]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:2: 9:2 + bb5: { + _0 = const (); // bb5[0]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:21: 7:10 + // ty::Const + // + ty: () + // + val: Value(Scalar()) + // mir::Constant + // + span: $DIR/simplify-locals-fixedpoint.rs:5:21: 7:10 + // + literal: Const { ty: (), val: Value(Scalar()) } + goto -> bb6; // bb5[1]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:5:9: 7:10 + } + + bb6: { + StorageDead(_7); // bb6[0]: scope 1 at $DIR/simplify-locals-fixedpoint.rs:8:5: 8:6 + StorageDead(_6); // bb6[1]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:8:5: 8:6 + goto -> bb7; // bb6[2]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:4:5: 8:6 + } + + bb7: { + drop(_1) -> bb8; // bb7[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2 + } + + bb8: { + StorageDead(_1); // bb8[0]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:1: 9:2 + return; // bb8[1]: scope 0 at $DIR/simplify-locals-fixedpoint.rs:9:2: 9:2 } }