-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
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.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
If we generate the MIR for
fn black_box<T>(t: T) -> T { t }
fn main() {
let x = black_box(42);
let y = if x == 43 {
"foo"
} else {
"bar"
};
}
we get something like
_3 = Eq(move _4, const 43i32);
StorageDead(_4);
switchInt(_3) -> [false: bb2, otherwise: bb3];
which we could also write as
switchInt(_4) -> [43i32: bb3, otherwise: bb2];
(plus move the StorageDead
to the beginning of bb2
and bb3
). The same goes for !=
(Ne
).
cc @rust-lang/wg-mir-opt
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.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.