-
Notifications
You must be signed in to change notification settings - Fork 13.3k
AddNicheCases MirPass #95652
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
AddNicheCases MirPass #95652
Conversation
Some changes occured to rustc_codegen_cranelift cc @bjorn3 Some changes occured to the CTFE / Miri engine cc @rust-lang/miri Some changes occurred in src/tools/clippy. cc @rust-lang/clippy |
r? @wesleywiser (rust-highfive has picked a reviewer for you, use r? to override) |
This was part of PR #94075, but it was requested that I split this and the actual niche-filling optimization into two parts. |
d835635
to
81d3e82
Compare
This comment has been minimized.
This comment has been minimized.
81d3e82
to
9247688
Compare
This pass optimizes switches on the discriminant of a niche-optimized enum.
9247688
to
9f84791
Compare
Considering the crater results from the original PR, I think we should run this PR against all the tests that failed |
Wait, this is an optimization, why would it have any impact on crate test failures? |
This seems like it removes the assignment to However, I have more general concerns about this going into MIR opts. MIR is generally supposed to be layout independent, and it being pre-monomorphization means that this opt sometimes won't fire for not great reasons. Especially the prospect of changing one of the key types (
|
LLVM certainly does not figure this out currently. And I'm not sure it can in general. I'll have to revisit this when I can sit down and think about it, but when LLVM IR is emitted, information about what are valid values for the niche is lost, so LLVM doesn't know there's only a handful of extra branches it would need to create. That said, I take your point about |
Yeah, I had misunderstood a message in the other PR as implying this was just for compile times. Imo this makes it even more important that this fires consistently though |
☔ The latest upstream changes (presumably #95966) made this pull request unmergeable. Please resolve the merge conflicts. |
Closing this as it seems it's no longer necessary for performance. |
This pass optimizes switches on the discriminant of a niche-optimized enum.