Skip to content

Conversation

simonvandel
Copy link
Contributor

@simonvandel simonvandel commented Aug 29, 2020

Add peephole optimization that simplifies Ne(_1, false) and Ne(false, _1) into _1. Similarly handles Eq(_1, true) and Eq(true, _1).

This was observed emitted from the MatchBranchSimplification pass.

@rust-highfive
Copy link
Contributor

r? @davidtwco

(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 Aug 29, 2020
Copy link
Contributor

@pickfire pickfire left a comment

Choose a reason for hiding this comment

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

I don't know much about peephole optimization but looks good to me.

@pickfire
Copy link
Contributor

Would this affect compile time? Should we run a timer?

@simonvandel
Copy link
Contributor Author

My intuition says that this shouldn't be that expensive but let's try perf bot to be sure?

@pickfire
Copy link
Contributor

@jyn514 Can you please help to run perf bot?

Copy link
Member

@davidtwco davidtwco left a comment

Choose a reason for hiding this comment

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

LGTM, r=me after perf

@davidtwco
Copy link
Member

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Collaborator

bors commented Aug 30, 2020

@davidtwco: 🔑 Insufficient privileges: not in try users

@davidtwco
Copy link
Member

@bors try

@bors
Copy link
Collaborator

bors commented Aug 30, 2020

⌛ Trying commit 320929a2d83ac8a960254eb89380e08dd5f58c55 with merge 13cacc3bbd9269bca180ad9e3a9d2bed057b60d1...

@bors
Copy link
Collaborator

bors commented Aug 30, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: 13cacc3bbd9269bca180ad9e3a9d2bed057b60d1 (13cacc3bbd9269bca180ad9e3a9d2bed057b60d1)

@rust-timer
Copy link
Collaborator

Queued 13cacc3bbd9269bca180ad9e3a9d2bed057b60d1 with parent b1d092c, future comparison URL.

@jyn514 jyn514 added A-mir-opt Area: MIR optimizations T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 30, 2020
@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (13cacc3bbd9269bca180ad9e3a9d2bed057b60d1): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never

@simonvandel
Copy link
Contributor Author

@davidtwco rebased on master to fix merge conflicts. It should be ready for a new bors try

@davidtwco
Copy link
Member

I'm not sure what conclusions can be drawn from the perf results - going to let someone else take a look before merging.

r? @wesleywiser

@davidtwco rebased on master to fix merge conflicts. It should be ready for a new bors try

I don't think we'll need another perf run, so another try build isn't necessary.

@wesleywiser
Copy link
Member

This looks good to me but I think for consistency we should do the same thing for Eq(_, true) | Eq(true, _). @simonvandel if you don't want to do that in the PR, let me know so we can open an issue instead and someone else can work on it.

@simonvandel
Copy link
Contributor Author

I can extend the PR to also handle the Eq case today, sure.

@simonvandel simonvandel changed the title MIR peephole optimize Ne(_1, false) into _1 MIR peephole optimize {Ne, Eq}(_1, false) into _1 Sep 3, 2020
@simonvandel
Copy link
Contributor Author

@wesleywiser added a new commit so that Eq is handled similarly

@wesleywiser
Copy link
Member

We usually do not rollup MIR optimizations even if they don't seem to have a performance impact because it would be best for bisection purposes if this does not end up in a rollup. Therefore

@bors r+ rollup=never

@bors
Copy link
Collaborator

bors commented Sep 3, 2020

📌 Commit 14cd6da2fdcf38d7c226ea8bfaf530357153e0e1 has been approved by wesleywiser

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 3, 2020
@pickfire
Copy link
Contributor

pickfire commented Sep 4, 2020

@wesleywiser Do we usually not run timer for this?

@wesleywiser
Copy link
Member

@pickfire I think since just the Ne optimization had little effect, both the Ne and Eq ones will probably not have a huge effect either. perf.rlo will run on the merge commit so we will be able to see exactly what the impact is.

@bors
Copy link
Collaborator

bors commented Sep 4, 2020

⌛ Testing commit 14cd6da2fdcf38d7c226ea8bfaf530357153e0e1 with merge e87c8a880736e304322e8d5be6b51ee33a2dd162...

@bors
Copy link
Collaborator

bors commented Sep 4, 2020

💔 Test failed - checks-actions

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Sep 4, 2020
@simonvandel
Copy link
Contributor Author

So I don't know why exactly the test failed:

-	  fn opt(_1: std::option::Option<()>) -> bool {
+	  fn opt(_1: Option<()>) -> bool {

I rebased on master locally, rebless and that did change my test. So i have now force pushed that. @wesleywiser can you start the bors dance again?

@nagisa
Copy link
Member

nagisa commented Sep 6, 2020

@bors r=wesleywiser

@bors
Copy link
Collaborator

bors commented Sep 6, 2020

📌 Commit 9b0fc62 has been approved by wesleywiser

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Sep 6, 2020
@bors
Copy link
Collaborator

bors commented Sep 6, 2020

⌛ Testing commit 9b0fc62 with merge 4b65872...

@bors
Copy link
Collaborator

bors commented Sep 6, 2020

☀️ Test successful - checks-actions, checks-azure
Approved by: wesleywiser
Pushing 4b65872 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 6, 2020
@bors bors merged commit 4b65872 into rust-lang:master Sep 6, 2020
@rustbot rustbot added this to the 1.48.0 milestone Sep 6, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-mir-opt Area: MIR optimizations merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants