rust-lang / rust-lang/rust

Tracking Issue for `uint_carryless_mul`

Open
#152,080 20 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

C-tracking-issue T-libs
Dominant language
Rust
Stars
119k
Forks
16.1k
PR merge metrics
PR metrics pending

Description

View all comments

Feature gate: #![feature(uint_carryless_mul)]

This is a tracking issue for functions that return the carryless product (XOR multiplication) of unsigned integers.
carryless_mul returns the low-order bits of the result, and widening_carryless_mul returns the full result in the next wider unsigned integer type.

Public API

widening_carryless_mul is not implemented for u128 because there is no larger integer type to return.

impl uN {
    /// Returns the low-order bits of the carryless product of `self` and `rhs`.
    pub const fn carryless_mul(self, rhs: Self) -> Self;
}

impl u8 {
    /// Returns the full carryless product result of `self` and `rhs` in the next wider power-of-two unsigned integer.
    pub const fn widening_carryless_mul(self, rhs: Self) -> u16;
}
impl u16 {
    pub const fn widening_carryless_mul(self, rhs: Self) -> u32;
}
impl u32 {
    pub const fn widening_carryless_mul(self, rhs: Self) -> u64;
}
impl u64 {
    pub const fn widening_carryless_mul(self, rhs: Self) -> u128;
}
Steps / History
Unresolved Questions
  • carrying_carryless_mul?: In the ACP, there was a voicing of desire for a function that returned the product as a 2-sized tuple with the same sized integer, (Self, Self).
  • Evaluate the quality of codegen before stabilization: Not all architectures have these operations as hardware instructions and the instructions are not uniform in their integer coverage, nor are the hardware instructions part of the baseline of some targets. However, even without hardware instructions, the intrinsics that these functions wrap should produce equal or better code than a (naive) user implementation.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Read the ACP in libs-team issue 738 and the implementation in pull request 152132, then review the feature-gated public API and the stabilization guidance linked in the issue. Done means resolving the carrying_carryless_mul and codegen questions and completing a stabilization PR after the final comment period.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
compilers
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.