diff options
Diffstat (limited to 'compiler/rustc_mir_transform/src')
| -rw-r--r-- | compiler/rustc_mir_transform/src/jump_threading.rs | 10 |
1 files changed, 6 insertions, 4 deletions
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"); |
