Simplify assert terminator only if condition evaluates to expected value
This commit is contained in:
parent
22e6b9c689
commit
a9470d0522
@ -49,9 +49,10 @@ impl<'tcx> MirPass<'tcx> for SimplifyBranches {
|
|||||||
}
|
}
|
||||||
TerminatorKind::Assert {
|
TerminatorKind::Assert {
|
||||||
target, cond: Operand::Constant(ref c), expected, ..
|
target, cond: Operand::Constant(ref c), expected, ..
|
||||||
} if (c.literal.try_eval_bool(tcx, param_env) == Some(true)) == expected => {
|
} => match c.literal.try_eval_bool(tcx, param_env) {
|
||||||
TerminatorKind::Goto { target }
|
Some(v) if v == expected => TerminatorKind::Goto { target },
|
||||||
}
|
_ => continue,
|
||||||
|
},
|
||||||
TerminatorKind::FalseEdge { real_target, .. } => {
|
TerminatorKind::FalseEdge { real_target, .. } => {
|
||||||
TerminatorKind::Goto { target: real_target }
|
TerminatorKind::Goto { target: real_target }
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user