diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2023-10-19 16:21:27 +0000 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2023-10-21 07:08:53 +0000 |
| commit | 66ec098ea7804ce8d02275cd754ccdcd7813bfdf (patch) | |
| tree | e74179530a91eacc4ddcf31682c58838c30802c9 /compiler | |
| parent | d5b21ef96bb9e4824b4651bfcf25a42465767a78 (diff) | |
| download | rust-66ec098ea7804ce8d02275cd754ccdcd7813bfdf.tar.gz rust-66ec098ea7804ce8d02275cd754ccdcd7813bfdf.zip | |
Simplify static if handling.
Diffstat (limited to 'compiler')
| -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"); |
