From 66ec098ea7804ce8d02275cd754ccdcd7813bfdf Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Thu, 19 Oct 2023 16:21:27 +0000 Subject: Simplify static if handling. --- compiler/rustc_mir_transform/src/jump_threading.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'compiler/rustc_mir_transform/src') diff --git a/compiler/rustc_mir_transform/src/jump_threading.rs b/compiler/rustc_mir_transform/src/jump_threading.rs index 5f0e7fcf2d2..19ba403ec6c 100644 --- a/compiler/rustc_mir_transform/src/jump_threading.rs +++ b/compiler/rustc_mir_transform/src/jump_threading.rs @@ -571,12 +571,14 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> { debug!(?target_bb, ?c.target, "register"); self.opportunities.push(ThreadingOpportunity { chain: vec![], target: c.target }); } - } else if target_bb == targets.otherwise() { - let (value, _, _) = targets.as_static_if()?; + } else if let Some((value, _, else_bb)) = targets.as_static_if() + && target_bb == else_bb + { let value = ScalarInt::try_from_uint(value, discr_layout.size)?; - // Likewise, we know that `discr != value`. That's a must weaker information, - // so we can only match the exact same condition. + // We only know that `discr != value`. That's much weaker information than + // the equality we had in the previous arm. All we can conclude is that + // the replacement condition `discr != value` can be threaded, and nothing else. for c in conditions.iter() { if c.value == value && c.polarity == Polarity::Ne { debug!(?target_bb, ?c.target, "register"); -- cgit 1.4.1-3-g733a5