-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Open
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Description
Consider the program:
fn program(x: u8) -> u8 {
match x {
1 | 2 | 3 | 4 => 0,
_ => 1,
}
}
We will generate the following SwitchInt
:
switchInt(_1) -> [1u8: bb2, 2u8: bb2, 3u8: bb2, 4u8: bb2, otherwise: bb1];
Ostensibly, something like this would be more profitable:
_2 = Le(const 1u8, _1);
switchInt(move _2) -> [false: bb2, otherwise: bb3];
This is the code you get from the range pattern 0..=4
.
Metadata
Metadata
Assignees
Labels
A-mir-optArea: MIR optimizationsArea: MIR optimizationsC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.I-slowIssue: Problems and improvements with respect to performance of generated code.Issue: Problems and improvements with respect to performance of generated code.T-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.