-
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
Fast isel dislikes switch, which pattern matching can generate #4353
Comments
Triage. As demonstrated below, we still generate fn main() {
match 1 {
0 => {}
_ => {}
};
} define void @_ZN4main18h7c52aaf9b95dc92af4v0.0E({ i64, %tydesc*, i8*, i8*, i8 }*) #4 {
"function top level":
%1 = alloca i64
store i64 1, i64* %1
%2 = load i64* %1
switch i64 %2, label %match_else [
i64 0, label %match_case
]
case_body: ; preds = %match_case
br label %join
case_body1: ; preds = %match_else
br label %join
match_else: ; preds = %"function top level"
br label %case_body1
match_case: ; preds = %"function top level"
br label %case_body
join: ; preds = %case_body1, %case_body
ret void
} |
P-low, not 1.0 blocker. |
Today, compiling with
No more |
I think fast isel is only ever attempted to be used when optimisations are off. Using fast isel makes compilation faster and so we want to ensure we're using with |
Ah, gotcha, that makes sense. Given that it's an optimization, I assumed that it would be with optimizations on. :) |
FastISel still dislikes (you can check for FastISel by running the LLVM IR through |
We may want to do this in the lowering for |
Generate br for all two target SwitchInts Instead of only for booleans. This means that `if let` also becomes a br. Apart from making the IR slightly simpler, this is supported by FastISel (rust-lang#4353).
Triage: I'm not aware of any changes, nor anybody working on something like this. @rust-lang/compiler do you think this ticket is useful? |
This ticket is still useful. That being said, benefits of fixing this are comparatively minor and there are bigger fish to catch. |
I think this needs a new repro, as the one above appears to have been fixed by #51323: https://play.rust-lang.org/?version=nightly&mode=debug&edition=2018&gist=5a29683164b1399f1a2418dd9f6718ee As an attempt, the following does generate a pub fn foo(c: i32) -> i32 {
match c {
0 => 1,
1 => 7,
_ => 2,
}
} How were you thinking of fixing this? Should there be a opt-level-zero-only MIR |
Unfortunately fastisel doesn't support quite a few things that are common in LLVM IR generated by Rust. It's probably not worthwhile to change the codegen for switch if we're quite likely to fail on an invoke or some scalar pair operation anyway. |
Closing per the same judgement as this sibling issue: #26600 (comment) |
We should use the compare mode otherwise.
The text was updated successfully, but these errors were encountered: