-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MIR building for match $c { true => $i, _ => $e }
is slow
#60571
Comments
CC #7462 |
May I volunteer in fixing? And can anyone help in pointing to the main file where match MIR is generated? |
rust/compiler/rustc_mir_build/src/thir/cx/expr.rs Lines 593 to 601 in a84d1b2
|
let chains are now de-sugared into |
It looks like today the match-generated MIR is basically the same "complexity" at least based on a visual inspection, so I'm going to go ahead and close this -- we can circle back if there's concrete results today that show otherwise. For pub fn foo_if(foo: bool) -> u32 {
if foo {
1
} else {
2
}
}
pub fn foo_match(foo: bool) -> u32 {
match foo {
true => 1,
false => 2,
}
} we get:
|
At the time of writing,
if $c { $i } else { $e }
builds MIR that is simpler and therefore is ~1-3% better in terms of compile times thanmatch $c { $i } else { $e }
. However, after theearly-opt
MIR optimization, they are basically the same.In #59288 we start desugaring
if
expressions tomatch
and so if we optimize for the special case of two match arms we can potentially improve compiles times.cc @oli-obk
The text was updated successfully, but these errors were encountered: