Skip to content

Commit 66ec098

Browse files
committed
Simplify static if handling.
1 parent d5b21ef commit 66ec098

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

compiler/rustc_mir_transform/src/jump_threading.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -571,12 +571,14 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
571571
debug!(?target_bb, ?c.target, "register");
572572
self.opportunities.push(ThreadingOpportunity { chain: vec![], target: c.target });
573573
}
574-
} else if target_bb == targets.otherwise() {
575-
let (value, _, _) = targets.as_static_if()?;
574+
} else if let Some((value, _, else_bb)) = targets.as_static_if()
575+
&& target_bb == else_bb
576+
{
576577
let value = ScalarInt::try_from_uint(value, discr_layout.size)?;
577578

578-
// Likewise, we know that `discr != value`. That's a must weaker information,
579-
// so we can only match the exact same condition.
579+
// We only know that `discr != value`. That's much weaker information than
580+
// the equality we had in the previous arm. All we can conclude is that
581+
// the replacement condition `discr != value` can be threaded, and nothing else.
580582
for c in conditions.iter() {
581583
if c.value == value && c.polarity == Polarity::Ne {
582584
debug!(?target_bb, ?c.target, "register");

0 commit comments

Comments
 (0)