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

Implement SpecOptionPartialEq for cmp::Ordering #107022

Merged
merged 2 commits into from Jan 28, 2023

Conversation

scottmcm
Copy link
Member

Noticed as I continue to explore options for having code using partial_cmp optimize better.

Before:

; Function Attrs: mustprogress nofree nosync nounwind willreturn uwtable
define noundef zeroext i1 @ordering_eq(i8 noundef %0, i8 noundef %1) unnamed_addr #0 {
start:
  %2 = icmp eq i8 %0, 2
  br i1 %2, label %bb1.i, label %bb3.i

bb1.i:                                            ; preds = %start
  %3 = icmp eq i8 %1, 2
  br label %"_ZN55_$LT$T$u20$as$u20$core..option..SpecOptionPartialEq$GT$2eq17hb7e7beacecde585fE.exit"

bb3.i:                                            ; preds = %start
  %.not.i = icmp ne i8 %1, 2
  %4 = icmp eq i8 %0, %1
  %spec.select.i = and i1 %.not.i, %4
  br label %"_ZN55_$LT$T$u20$as$u20$core..option..SpecOptionPartialEq$GT$2eq17hb7e7beacecde585fE.exit"

"_ZN55_$LT$T$u20$as$u20$core..option..SpecOptionPartialEq$GT$2eq17hb7e7beacecde585fE.exit": ; preds = %bb1.i, %bb3.i
  %.0.i = phi i1 [ %3, %bb1.i ], [ %spec.select.i, %bb3.i ]
  ret i1 %.0.i
}

After:

; Function Attrs: mustprogress nofree norecurse nosync nounwind readnone willreturn uwtable
define noundef zeroext i1 @ordering_eq(i8 noundef %0, i8 noundef %1) unnamed_addr #1 {
start:
  %2 = icmp eq i8 %0, %1
  ret i1 %2
}

(Which https://alive2.llvm.org/ce/z/-rop5r says LLVM could just do itself, but there's probably an issue already open for that problem from when this was originally looked at for Option<NonZeroU8> and friends.)

@rustbot
Copy link
Collaborator

rustbot commented Jan 18, 2023

r? @m-ou-se

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

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Jan 18, 2023
@rustbot

This comment was marked as resolved.

@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 18, 2023
@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jan 19, 2023
@m-ou-se
Copy link
Member

m-ou-se commented Jan 27, 2023

It seems worrying that rustc/llvm didn't optimize this.

but there's probably an issue already open for that problem

This PR seems fine for now (r=me), but can you please open an issue (if there isn't one already) and add a comment to SpecOptionPartialEq linking to that issue? It'd be great to be able to get rid of SpecOptionPartialEq again at some point.

@scottmcm
Copy link
Member Author

Issue found; Comment added; CI passed.

@bors r=m-ou-se

@bors
Copy link
Contributor

bors commented Jan 28, 2023

📌 Commit 3e9d1e4 has been approved by m-ou-se

It is now in the queue for this repository.

@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 Jan 28, 2023
bors added a commit to rust-lang-ci/rust that referenced this pull request Jan 28, 2023
…iaskrgr

Rollup of 8 pull requests

Successful merges:

 - rust-lang#107022 (Implement `SpecOptionPartialEq` for `cmp::Ordering`)
 - rust-lang#107100 (Use proper `InferCtxt` when probing for associated types in astconv)
 - rust-lang#107103 (Use new solver in `evaluate_obligation` query (when new solver is enabled))
 - rust-lang#107190 (Recover from more const arguments that are not wrapped in curly braces)
 - rust-lang#107306 (Correct suggestions for closure arguments that need a borrow)
 - rust-lang#107339 (internally change regions to be covariant)
 - rust-lang#107344 (Minor tweaks in the new solver)
 - rust-lang#107373 (Don't merge vtables when full debuginfo is enabled.)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 7b78b6a into rust-lang:master Jan 28, 2023
@rustbot rustbot added this to the 1.69.0 milestone Jan 28, 2023
@scottmcm scottmcm deleted the ordering-option-eq branch January 28, 2023 19:16
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 11, 2024
Remove an unneeded helper from the tuple library code

Thanks to rust-lang#107022, this is just what `==` does, so we don't need the helper here anymore.
matthiaskrgr added a commit to matthiaskrgr/rust that referenced this pull request Feb 11, 2024
…riplett

Remove an unneeded helper from the tuple library code

Thanks to rust-lang#107022, this is just what `==` does, so we don't need the helper here anymore.
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Feb 11, 2024
Rollup merge of rust-lang#118307 - scottmcm:tuple-eq-simpler, r=joshtriplett

Remove an unneeded helper from the tuple library code

Thanks to rust-lang#107022, this is just what `==` does, so we don't need the helper here anymore.
lnicola pushed a commit to lnicola/rust-analyzer that referenced this pull request Apr 7, 2024
Remove an unneeded helper from the tuple library code

Thanks to rust-lang/rust#107022, this is just what `==` does, so we don't need the helper here anymore.
RalfJung pushed a commit to RalfJung/rust-analyzer that referenced this pull request Apr 27, 2024
Remove an unneeded helper from the tuple library code

Thanks to rust-lang/rust#107022, this is just what `==` does, so we don't need the helper here anymore.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants