From 4547b622d8d29df964fa2914213088b148c498fc Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Wed, 17 Apr 2024 14:18:32 +0200 Subject: Merging upstream version 1.67.1+dfsg1. Signed-off-by: Daniel Baumann --- src/test/mir-opt/issues/issue-59352.rs | 19 ----- src/test/mir-opt/issues/issue-75439.rs | 18 ----- .../issue_59352.num_to_digit.PreCodegen.after.mir | 93 ++++++++++------------ src/test/mir-opt/issues/issue_59352.rs | 19 +++++ .../issue_75439.foo.MatchBranchSimplification.diff | 82 +++++++++---------- src/test/mir-opt/issues/issue_75439.rs | 18 +++++ 6 files changed, 118 insertions(+), 131 deletions(-) delete mode 100644 src/test/mir-opt/issues/issue-59352.rs delete mode 100644 src/test/mir-opt/issues/issue-75439.rs create mode 100644 src/test/mir-opt/issues/issue_59352.rs create mode 100644 src/test/mir-opt/issues/issue_75439.rs (limited to 'src/test/mir-opt/issues') diff --git a/src/test/mir-opt/issues/issue-59352.rs b/src/test/mir-opt/issues/issue-59352.rs deleted file mode 100644 index 1e0045555..000000000 --- a/src/test/mir-opt/issues/issue-59352.rs +++ /dev/null @@ -1,19 +0,0 @@ -// This test is a mirror of codegen/issue-59352.rs. -// The LLVM inliner doesn't inline `char::method::is_digit()` and so it doesn't recognize this case -// as effectively `if x.is_some() { x.unwrap() } else { 0 }`. -// -// Currently, the MIR optimizer isn't capable of removing the unreachable panic in this test case. -// Once the optimizer can do that, this test case will need to be updated and codegen/issue-59352.rs -// removed. - -// EMIT_MIR issue_59352.num_to_digit.PreCodegen.after.mir -// compile-flags: -Z mir-opt-level=3 -Z span_free_formats - -pub fn num_to_digit(num: char) -> u32 { - // CHECK-NOT: panic - if num.is_digit(8) { num.to_digit(8).unwrap() } else { 0 } -} - -pub fn main() { - num_to_digit('2'); -} diff --git a/src/test/mir-opt/issues/issue-75439.rs b/src/test/mir-opt/issues/issue-75439.rs deleted file mode 100644 index ae2e03631..000000000 --- a/src/test/mir-opt/issues/issue-75439.rs +++ /dev/null @@ -1,18 +0,0 @@ -// EMIT_MIR issue_75439.foo.MatchBranchSimplification.diff - -use std::mem::transmute; - -pub fn foo(bytes: [u8; 16]) -> Option<[u8; 4]> { - // big endian `u32`s - let dwords: [u32; 4] = unsafe { transmute(bytes) }; - const FF: u32 = 0x0000_ffff_u32.to_be(); - if let [0, 0, 0 | FF, ip] = dwords { - Some(unsafe { transmute(ip) }) - } else { - None - } -} - -fn main() { - let _ = foo([0; 16]); -} diff --git a/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir b/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir index f46c10711..5a2f4feff 100644 --- a/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir +++ b/src/test/mir-opt/issues/issue_59352.num_to_digit.PreCodegen.after.mir @@ -1,90 +1,77 @@ // MIR for `num_to_digit` after PreCodegen fn num_to_digit(_1: char) -> u32 { - debug num => _1; // in scope 0 at $DIR/issue-59352.rs:+0:21: +0:24 - let mut _0: u32; // return place in scope 0 at $DIR/issue-59352.rs:+0:35: +0:38 - let mut _2: char; // in scope 0 at $DIR/issue-59352.rs:+2:8: +2:11 - let mut _3: std::option::Option; // in scope 0 at $DIR/issue-59352.rs:+2:26: +2:41 - let mut _4: char; // in scope 0 at $DIR/issue-59352.rs:+2:26: +2:29 - let mut _5: u32; // in scope 0 at $DIR/issue-59352.rs:+2:8: +2:23 - let mut _12: isize; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - scope 1 (inlined char::methods::::is_digit) { // at $DIR/issue-59352.rs:14:8: 14:23 - debug self => _2; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - debug radix => _5; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let mut _6: &std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let _7: std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - let mut _8: char; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + debug num => _1; // in scope 0 at $DIR/issue_59352.rs:+0:21: +0:24 + let mut _0: u32; // return place in scope 0 at $DIR/issue_59352.rs:+0:35: +0:38 + let mut _2: std::option::Option; // in scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 + let mut _3: u32; // in scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 + let mut _9: isize; // in scope 0 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + scope 1 (inlined char::methods::::is_digit) { // at $DIR/issue_59352.rs:14:8: 14:23 + debug self => _1; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + debug radix => _3; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + let mut _4: &std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + let _5: std::option::Option; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + let mut _6: char; // in scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL scope 2 (inlined Option::::is_some) { // at $SRC_DIR/core/src/char/methods.rs:LL:COL - debug self => _6; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _9: isize; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + debug self => _4; // in scope 2 at $SRC_DIR/core/src/option.rs:LL:COL } } - scope 3 (inlined #[track_caller] Option::::unwrap) { // at $DIR/issue-59352.rs:14:26: 14:50 - debug self => _3; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _10: isize; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - let mut _11: !; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + scope 3 (inlined #[track_caller] Option::::unwrap) { // at $DIR/issue_59352.rs:14:26: 14:50 + debug self => _2; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _7: isize; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + let mut _8: !; // in scope 3 at $SRC_DIR/core/src/option.rs:LL:COL scope 4 { debug val => _0; // in scope 4 at $SRC_DIR/core/src/option.rs:LL:COL } } bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-59352.rs:+2:8: +2:11 - _2 = _1; // scope 0 at $DIR/issue-59352.rs:+2:8: +2:11 - StorageLive(_5); // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23 + StorageLive(_3); // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 + StorageLive(_4); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + StorageLive(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL StorageLive(_6); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageLive(_7); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageLive(_8); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _8 = _2; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _7 = char::methods::::to_digit(move _8, const 8_u32) -> bb5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + _6 = _1; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + _5 = char::methods::::to_digit(move _6, const 8_u32) -> bb5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/char/methods.rs:LL:COL // + literal: Const { ty: fn(char, u32) -> Option {char::methods::::to_digit}, val: Value() } } bb1: { - StorageDead(_12); // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23 - StorageLive(_3); // scope 0 at $DIR/issue-59352.rs:+2:26: +2:41 - StorageLive(_4); // scope 0 at $DIR/issue-59352.rs:+2:26: +2:29 - _4 = _1; // scope 0 at $DIR/issue-59352.rs:+2:26: +2:29 - _3 = char::methods::::to_digit(move _4, const 8_u32) -> bb2; // scope 0 at $DIR/issue-59352.rs:+2:26: +2:41 + StorageLive(_2); // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 + _2 = char::methods::::to_digit(move _1, const 8_u32) -> bb2; // scope 0 at $DIR/issue_59352.rs:+2:26: +2:41 // mir::Constant - // + span: $DIR/issue-59352.rs:14:30: 14:38 + // + span: $DIR/issue_59352.rs:14:30: 14:38 // + literal: Const { ty: fn(char, u32) -> Option {char::methods::::to_digit}, val: Value() } } bb2: { - StorageDead(_4); // scope 0 at $DIR/issue-59352.rs:+2:40: +2:41 - _10 = discriminant(_3); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - switchInt(move _10) -> [0_isize: bb6, 1_isize: bb8, otherwise: bb7]; // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + _7 = discriminant(_2); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + switchInt(move _7) -> [0_isize: bb6, 1_isize: bb8, otherwise: bb7]; // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL } bb3: { - StorageDead(_12); // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23 - _0 = const 0_u32; // scope 0 at $DIR/issue-59352.rs:+2:60: +2:61 - goto -> bb4; // scope 0 at $DIR/issue-59352.rs:+2:5: +2:63 + _0 = const 0_u32; // scope 0 at $DIR/issue_59352.rs:+2:60: +2:61 + goto -> bb4; // scope 0 at $DIR/issue_59352.rs:+2:5: +2:63 } bb4: { - return; // scope 0 at $DIR/issue-59352.rs:+3:2: +3:2 + return; // scope 0 at $DIR/issue_59352.rs:+3:2: +3:2 } bb5: { - _6 = &_7; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageDead(_8); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - _9 = discriminant((*_6)); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL - StorageLive(_12); // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL - _12 = move _9; // scope 2 at $SRC_DIR/core/src/macros/mod.rs:LL:COL + _4 = &_5; // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL StorageDead(_6); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageDead(_7); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL - StorageDead(_5); // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23 - StorageDead(_2); // scope 0 at $DIR/issue-59352.rs:+2:22: +2:23 - switchInt(move _12) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/issue-59352.rs:+2:8: +2:23 + _9 = discriminant((*_4)); // scope 2 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_4); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + StorageDead(_5); // scope 1 at $SRC_DIR/core/src/char/methods.rs:LL:COL + StorageDead(_3); // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 + switchInt(move _9) -> [1_isize: bb1, otherwise: bb3]; // scope 0 at $DIR/issue_59352.rs:+2:8: +2:23 } bb6: { - StorageLive(_11); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - _11 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + StorageLive(_8); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + _8 = core::panicking::panic(const "called `Option::unwrap()` on a `None` value"); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL // mir::Constant // + span: $SRC_DIR/core/src/option.rs:LL:COL // + literal: Const { ty: fn(&'static str) -> ! {core::panicking::panic}, val: Value() } @@ -98,8 +85,8 @@ fn num_to_digit(_1: char) -> u32 { } bb8: { - _0 = move ((_3 as Some).0: u32); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL - StorageDead(_3); // scope 0 at $DIR/issue-59352.rs:+2:49: +2:50 - goto -> bb4; // scope 0 at $DIR/issue-59352.rs:+2:5: +2:63 + _0 = move ((_2 as Some).0: u32); // scope 3 at $SRC_DIR/core/src/option.rs:LL:COL + StorageDead(_2); // scope 0 at $DIR/issue_59352.rs:+2:49: +2:50 + goto -> bb4; // scope 0 at $DIR/issue_59352.rs:+2:5: +2:63 } } diff --git a/src/test/mir-opt/issues/issue_59352.rs b/src/test/mir-opt/issues/issue_59352.rs new file mode 100644 index 000000000..1e0045555 --- /dev/null +++ b/src/test/mir-opt/issues/issue_59352.rs @@ -0,0 +1,19 @@ +// This test is a mirror of codegen/issue-59352.rs. +// The LLVM inliner doesn't inline `char::method::is_digit()` and so it doesn't recognize this case +// as effectively `if x.is_some() { x.unwrap() } else { 0 }`. +// +// Currently, the MIR optimizer isn't capable of removing the unreachable panic in this test case. +// Once the optimizer can do that, this test case will need to be updated and codegen/issue-59352.rs +// removed. + +// EMIT_MIR issue_59352.num_to_digit.PreCodegen.after.mir +// compile-flags: -Z mir-opt-level=3 -Z span_free_formats + +pub fn num_to_digit(num: char) -> u32 { + // CHECK-NOT: panic + if num.is_digit(8) { num.to_digit(8).unwrap() } else { 0 } +} + +pub fn main() { + num_to_digit('2'); +} diff --git a/src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff b/src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff index 2ee4332ad..87066cc62 100644 --- a/src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff +++ b/src/test/mir-opt/issues/issue_75439.foo.MatchBranchSimplification.diff @@ -2,17 +2,17 @@ + // MIR for `foo` after MatchBranchSimplification fn foo(_1: [u8; 16]) -> Option<[u8; 4]> { - debug bytes => _1; // in scope 0 at $DIR/issue-75439.rs:+0:12: +0:17 - let mut _0: std::option::Option<[u8; 4]>; // return place in scope 0 at $DIR/issue-75439.rs:+0:32: +0:47 - let _2: [u32; 4]; // in scope 0 at $DIR/issue-75439.rs:+2:9: +2:15 - let mut _3: [u8; 16]; // in scope 0 at $DIR/issue-75439.rs:+2:47: +2:52 - let mut _5: [u8; 4]; // in scope 0 at $DIR/issue-75439.rs:+5:14: +5:38 - let mut _6: u32; // in scope 0 at $DIR/issue-75439.rs:+5:33: +5:35 + debug bytes => _1; // in scope 0 at $DIR/issue_75439.rs:+0:12: +0:17 + let mut _0: std::option::Option<[u8; 4]>; // return place in scope 0 at $DIR/issue_75439.rs:+0:32: +0:47 + let _2: [u32; 4]; // in scope 0 at $DIR/issue_75439.rs:+2:9: +2:15 + let mut _3: [u8; 16]; // in scope 0 at $DIR/issue_75439.rs:+2:47: +2:52 + let mut _5: [u8; 4]; // in scope 0 at $DIR/issue_75439.rs:+5:14: +5:38 + let mut _6: u32; // in scope 0 at $DIR/issue_75439.rs:+5:33: +5:35 scope 1 { - debug dwords => _2; // in scope 1 at $DIR/issue-75439.rs:+2:9: +2:15 + debug dwords => _2; // in scope 1 at $DIR/issue_75439.rs:+2:9: +2:15 scope 3 { - debug ip => _4; // in scope 3 at $DIR/issue-75439.rs:+4:27: +4:29 - let _4: u32; // in scope 3 at $DIR/issue-75439.rs:+4:27: +4:29 + debug ip => _4; // in scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 + let _4: u32; // in scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 scope 4 { } } @@ -21,69 +21,69 @@ } bb0: { - StorageLive(_2); // scope 0 at $DIR/issue-75439.rs:+2:9: +2:15 - StorageLive(_3); // scope 2 at $DIR/issue-75439.rs:+2:47: +2:52 - _3 = _1; // scope 2 at $DIR/issue-75439.rs:+2:47: +2:52 - _2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue-75439.rs:+2:37: +2:53 + StorageLive(_2); // scope 0 at $DIR/issue_75439.rs:+2:9: +2:15 + StorageLive(_3); // scope 2 at $DIR/issue_75439.rs:+2:47: +2:52 + _3 = _1; // scope 2 at $DIR/issue_75439.rs:+2:47: +2:52 + _2 = transmute::<[u8; 16], [u32; 4]>(move _3) -> bb1; // scope 2 at $DIR/issue_75439.rs:+2:37: +2:53 // mir::Constant - // + span: $DIR/issue-75439.rs:7:37: 7:46 + // + span: $DIR/issue_75439.rs:7:37: 7:46 // + literal: Const { ty: unsafe extern "rust-intrinsic" fn([u8; 16]) -> [u32; 4] {transmute::<[u8; 16], [u32; 4]>}, val: Value() } } bb1: { - StorageDead(_3); // scope 2 at $DIR/issue-75439.rs:+2:52: +2:53 - switchInt(_2[0 of 4]) -> [0_u32: bb2, otherwise: bb8]; // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30 + StorageDead(_3); // scope 2 at $DIR/issue_75439.rs:+2:52: +2:53 + switchInt(_2[0 of 4]) -> [0_u32: bb2, otherwise: bb8]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } bb2: { - switchInt(_2[1 of 4]) -> [0_u32: bb3, otherwise: bb8]; // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30 + switchInt(_2[1 of 4]) -> [0_u32: bb3, otherwise: bb8]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } bb3: { - switchInt(_2[2 of 4]) -> [0_u32: bb5, 4294901760_u32: bb6, otherwise: bb8]; // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30 + switchInt(_2[2 of 4]) -> [0_u32: bb5, 4294901760_u32: bb6, otherwise: bb8]; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } bb4: { - StorageLive(_5); // scope 3 at $DIR/issue-75439.rs:+5:14: +5:38 - StorageLive(_6); // scope 4 at $DIR/issue-75439.rs:+5:33: +5:35 - _6 = _4; // scope 4 at $DIR/issue-75439.rs:+5:33: +5:35 - _5 = transmute::(move _6) -> bb7; // scope 4 at $DIR/issue-75439.rs:+5:23: +5:36 + StorageLive(_5); // scope 3 at $DIR/issue_75439.rs:+5:14: +5:38 + StorageLive(_6); // scope 4 at $DIR/issue_75439.rs:+5:33: +5:35 + _6 = _4; // scope 4 at $DIR/issue_75439.rs:+5:33: +5:35 + _5 = transmute::(move _6) -> bb7; // scope 4 at $DIR/issue_75439.rs:+5:23: +5:36 // mir::Constant - // + span: $DIR/issue-75439.rs:10:23: 10:32 + // + span: $DIR/issue_75439.rs:10:23: 10:32 // + literal: Const { ty: unsafe extern "rust-intrinsic" fn(u32) -> [u8; 4] {transmute::}, val: Value() } } bb5: { - StorageLive(_4); // scope 3 at $DIR/issue-75439.rs:+4:27: +4:29 - _4 = _2[3 of 4]; // scope 3 at $DIR/issue-75439.rs:+4:27: +4:29 - goto -> bb4; // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30 + StorageLive(_4); // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 + _4 = _2[3 of 4]; // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 + goto -> bb4; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } bb6: { - StorageLive(_4); // scope 3 at $DIR/issue-75439.rs:+4:27: +4:29 - _4 = _2[3 of 4]; // scope 3 at $DIR/issue-75439.rs:+4:27: +4:29 - goto -> bb4; // scope 3 at $DIR/issue-75439.rs:+4:12: +4:30 + StorageLive(_4); // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 + _4 = _2[3 of 4]; // scope 3 at $DIR/issue_75439.rs:+4:27: +4:29 + goto -> bb4; // scope 3 at $DIR/issue_75439.rs:+4:12: +4:30 } bb7: { - StorageDead(_6); // scope 4 at $DIR/issue-75439.rs:+5:35: +5:36 - Deinit(_0); // scope 3 at $DIR/issue-75439.rs:+5:9: +5:39 - ((_0 as Some).0: [u8; 4]) = move _5; // scope 3 at $DIR/issue-75439.rs:+5:9: +5:39 - discriminant(_0) = 1; // scope 3 at $DIR/issue-75439.rs:+5:9: +5:39 - StorageDead(_5); // scope 3 at $DIR/issue-75439.rs:+5:38: +5:39 - StorageDead(_4); // scope 1 at $DIR/issue-75439.rs:+6:5: +6:6 - goto -> bb9; // scope 1 at $DIR/issue-75439.rs:+4:5: +8:6 + StorageDead(_6); // scope 4 at $DIR/issue_75439.rs:+5:35: +5:36 + Deinit(_0); // scope 3 at $DIR/issue_75439.rs:+5:9: +5:39 + ((_0 as Some).0: [u8; 4]) = move _5; // scope 3 at $DIR/issue_75439.rs:+5:9: +5:39 + discriminant(_0) = 1; // scope 3 at $DIR/issue_75439.rs:+5:9: +5:39 + StorageDead(_5); // scope 3 at $DIR/issue_75439.rs:+5:38: +5:39 + StorageDead(_4); // scope 1 at $DIR/issue_75439.rs:+6:5: +6:6 + goto -> bb9; // scope 1 at $DIR/issue_75439.rs:+4:5: +8:6 } bb8: { - Deinit(_0); // scope 1 at $DIR/issue-75439.rs:+7:9: +7:13 - discriminant(_0) = 0; // scope 1 at $DIR/issue-75439.rs:+7:9: +7:13 - goto -> bb9; // scope 1 at $DIR/issue-75439.rs:+4:5: +8:6 + Deinit(_0); // scope 1 at $DIR/issue_75439.rs:+7:9: +7:13 + discriminant(_0) = 0; // scope 1 at $DIR/issue_75439.rs:+7:9: +7:13 + goto -> bb9; // scope 1 at $DIR/issue_75439.rs:+4:5: +8:6 } bb9: { - StorageDead(_2); // scope 0 at $DIR/issue-75439.rs:+9:1: +9:2 - return; // scope 0 at $DIR/issue-75439.rs:+9:2: +9:2 + StorageDead(_2); // scope 0 at $DIR/issue_75439.rs:+9:1: +9:2 + return; // scope 0 at $DIR/issue_75439.rs:+9:2: +9:2 } } diff --git a/src/test/mir-opt/issues/issue_75439.rs b/src/test/mir-opt/issues/issue_75439.rs new file mode 100644 index 000000000..ae2e03631 --- /dev/null +++ b/src/test/mir-opt/issues/issue_75439.rs @@ -0,0 +1,18 @@ +// EMIT_MIR issue_75439.foo.MatchBranchSimplification.diff + +use std::mem::transmute; + +pub fn foo(bytes: [u8; 16]) -> Option<[u8; 4]> { + // big endian `u32`s + let dwords: [u32; 4] = unsafe { transmute(bytes) }; + const FF: u32 = 0x0000_ffff_u32.to_be(); + if let [0, 0, 0 | FF, ip] = dwords { + Some(unsafe { transmute(ip) }) + } else { + None + } +} + +fn main() { + let _ = foo([0; 16]); +} -- cgit v1.2.3