Simplify static if handling.

This commit is contained in:
Camille GILLOT 2023-10-19 16:21:27 +00:00
parent d5b21ef96b
commit 66ec098ea7

View File

@ -571,12 +571,14 @@ impl<'tcx, 'a> TOFinder<'tcx, 'a> {
debug!(?target_bb, ?c.target, "register"); debug!(?target_bb, ?c.target, "register");
self.opportunities.push(ThreadingOpportunity { chain: vec![], target: c.target }); self.opportunities.push(ThreadingOpportunity { chain: vec![], target: c.target });
} }
} else if target_bb == targets.otherwise() { } else if let Some((value, _, else_bb)) = targets.as_static_if()
let (value, _, _) = targets.as_static_if()?; && target_bb == else_bb
{
let value = ScalarInt::try_from_uint(value, discr_layout.size)?; let value = ScalarInt::try_from_uint(value, discr_layout.size)?;
// Likewise, we know that `discr != value`. That's a must weaker information, // We only know that `discr != value`. That's much weaker information than
// so we can only match the exact same condition. // 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() { for c in conditions.iter() {
if c.value == value && c.polarity == Polarity::Ne { if c.value == value && c.polarity == Polarity::Ne {
debug!(?target_bb, ?c.target, "register"); debug!(?target_bb, ?c.target, "register");