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

Tracking issue for reversing the bit pattern in an integer #48763

Closed
Amanieu opened this issue Mar 6, 2018 · 9 comments · Fixed by #61364
Closed

Tracking issue for reversing the bit pattern in an integer #48763

Amanieu opened this issue Mar 6, 2018 · 9 comments · Fixed by #61364
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@Amanieu
Copy link
Member

Amanieu commented Mar 6, 2018

Tracking issue for the reverse_bits method implemented in #48573.

impl {integer} {
    pub fn reverse_bits(self) -> Self;
}
@sfackler sfackler added T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. B-unstable Blocker: Implemented in the nightly compiler and unstable. labels Mar 6, 2018
@TimNN TimNN added the C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. label Mar 6, 2018
@SimonSapin
Copy link
Contributor

Motivation from #32798 (comment)

On ARM, there are dedicated instructions for reversing bits. The intrinsic would lower to a single RBIT instruction.

@zbentley
Copy link

I'm a user that would benefit from this being stabilized. No worries if I have to wait until an LLVM requirement version bump, though. We would benefit from it, but aren't in a position to contribute support, so we are happy to wait/offer testing or documentation help.

@raphaelcohn
Copy link

Just to add to this, these intrinsics are useful for formatting data that is represented bit reversed, such as the IEEE standard for bit-reversed MACs, token ring addresses, etc.

@nvzqz
Copy link
Contributor

nvzqz commented May 17, 2019

I'd really like to make use of this in my chess engine. What's the status on this?

@SimonSapin
Copy link
Contributor

This thread or #48573 do not show a serious issue as far as I can tell.

@rfcbot fcp merge

@rfcbot
Copy link

rfcbot commented May 19, 2019

Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged team members:

No concerns currently listed.

Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@rfcbot rfcbot added proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. labels May 19, 2019
@SimonSapin
Copy link
Contributor

#48573 (comment) says

keep in mind that the performance of LLVM's generic bitreverse solution can vary greatly depending on the types involved, your target architecture, and what the rest of your code does around it: https://bugs.llvm.org/show_bug.cgi?id=31810

If your target has a bit reverse instruction (only ARMv8 as far as I know) then everything should be fine.

The linked bug has some discussion about changing the code emitted when there is not a dedicated instruction. That has not yet lead to an LLVM change, but it doesn’t seem serious enough to me that we shouldn’t expose this at all.


Since we also have a [T]::reserve(&mut self) that works in place, it’s possible that someone assumes reverse_bits does the same. So it could be good to add #[must_use] to these methods. @nvzqz, do you want to send a PR to do that?

@rfcbot rfcbot added the final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. label May 20, 2019
@rfcbot
Copy link

rfcbot commented May 20, 2019

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot rfcbot removed the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label May 20, 2019
Centril added a commit to Centril/rust that referenced this issue May 25, 2019
Annotate each `reverse_bits` with `#[must_use]`

Because the name sounds like an in-place mutation like `[T]::reverse(&mut self)`, it may be confused for one.

This change was requested at rust-lang#48763 (comment).
@rfcbot rfcbot added finished-final-comment-period The final comment period is finished for this PR / Issue. and removed final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. labels May 30, 2019
@rfcbot
Copy link

rfcbot commented May 30, 2019

The final comment period, with a disposition to merge, as per the review above, is now complete.

As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.

The RFC will be merged soon.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. C-tracking-issue Category: A tracking issue for an RFC or an unstable feature. disposition-merge This issue / PR is in PFCP or FCP with a disposition to merge it. finished-final-comment-period The final comment period is finished for this PR / Issue. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants