Skip to content

Commit

Permalink
Remove restrictions on small enum statements such as Order, `Option…
Browse files Browse the repository at this point in the history
…` or `Result`

`early-tailduplication` is only a problem when there are a significant number of branches.
  • Loading branch information
DianQK committed Mar 9, 2024
1 parent 01df146 commit 1b13179
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ impl<'tcx> MirPass<'tcx> for UnreachableEnumBranching {
// ```
let otherwise_is_last_variant = !otherwise_is_empty_unreachable
&& allowed_variants.len() == 1
&& check_successors(&body.basic_blocks, targets.otherwise());
// Despite the LLVM issue, we hope that small enum can still be transformed.
// This is valuable for both `a <= b` and `if let Some/Ok(v)`.
&& (targets.all_targets().len() <= 3
|| check_successors(&body.basic_blocks, targets.otherwise()));
let replace_otherwise_to_unreachable = otherwise_is_last_variant
|| (!otherwise_is_empty_unreachable && allowed_variants.is_empty());

Expand Down

0 comments on commit 1b13179

Please sign in to comment.