Skip to content
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

Add identity match mir pass #77770

Closed
wants to merge 2 commits into from
Closed

Conversation

JulianKnodt
Copy link
Contributor

Adds in a mir-optimization pass for optimizing over

match some_enum {
  Var1(x) => Var1(x),
  Var2(y) => Var2(y),
}

While browsing through old issues I found #38349, and thought it would be simple enough to write a mir optimization pass for it, even though the LLVM looks to be fairly optimized.

@rust-highfive
Copy link
Collaborator

r? @eddyb

(rust_highfive has picked a reviewer for you, use r? to override)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Oct 9, 2020
@camelid camelid added A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html A-mir-opt Area: MIR optimizations labels Oct 10, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Nov 26, 2020

r? @oli-obk

@rust-highfive rust-highfive assigned oli-obk and unassigned eddyb Nov 26, 2020

bb0: {
_2 = discriminant(_1); // scope 0 at $DIR/match_identity.rs:18:9: 18:14
switchInt(move _2) -> [0_isize: bb2, otherwise: bb1]; // scope 0 at $DIR/match_identity.rs:18:9: 18:14
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it doesn't look like your optimization actually gets applied

@JulianKnodt
Copy link
Contributor Author

ah sorry, I left this up for a while because I was not sure if it was a good idea, but I think I'll just close it because it's likely to slow down the parsing more and can probably just be handled when the MIR is created.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html A-mir-opt Area: MIR optimizations S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants