Skip to content

Commit

Permalink
Auto merge of rust-lang#126171 - RalfJung:simd_bitmask_multibyte, r=w…
Browse files Browse the repository at this point in the history
…orkingjubilee

simd_bitmask intrinsic: add a non-power-of-2 multi-byte example

r? `@calebzulawski` `@workingjubilee`
  • Loading branch information
bors committed Jul 5, 2024
2 parents de4f5c2 + 3edb521 commit 03d11c2
Showing 1 changed file with 13 additions and 6 deletions.
19 changes: 13 additions & 6 deletions core/src/intrinsics/simd.rs
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ extern "rust-intrinsic" {
/// `T` must be an integer vector.
///
/// `U` must be either the smallest unsigned integer with at least as many bits as the length
/// of `T`, or the smallest array of `u8` with as many bits as the length of `T`.
/// of `T`, or the smallest array of `u8` with at least as many bits as the length of `T`.
///
/// Each element is truncated to a single bit and packed into the result.
///
Expand All @@ -472,12 +472,19 @@ extern "rust-intrinsic" {
/// * On little endian, the least significant bit corresponds to the first vector element.
/// * On big endian, the least significant bit corresponds to the last vector element.
///
/// For example, `[!0, 0, !0, !0]` packs to `0b1101` on little endian and `0b1011` on big
/// endian.
/// For example, `[!0, 0, !0, !0]` packs to
/// - `0b1101u8` or `[0b1101]` on little endian, and
/// - `0b1011u8` or `[0b1011]` on big endian.
///
/// To consider a larger example, `[!0, 0, 0, 0, 0, 0, 0, 0, !0, !0, 0, 0, 0, 0, !0, 0]` packs
/// to `[0b00000001, 0b01000011]` or `0b0100001100000001` on little endian, and `[0b10000000,
/// 0b11000010]` or `0b1000000011000010` on big endian.
/// To consider a larger example,
/// `[!0, 0, 0, 0, 0, 0, 0, 0, !0, !0, 0, 0, 0, 0, !0, 0]` packs to
/// - `0b0100001100000001u16` or `[0b00000001, 0b01000011]` on little endian, and
/// - `0b1000000011000010u16` or `[0b10000000, 0b11000010]` on big endian.
///
/// And finally, a non-power-of-2 example with multiple bytes:
/// `[!0, !0, 0, !0, 0, 0, !0, 0, !0, 0]` packs to
/// - `0b0101001011u16` or `[0b01001011, 0b01]` on little endian, and
/// - `0b1101001010u16` or `[0b11, 0b01001010]` on big endian.
///
/// # Safety
/// `x` must contain only `0` and `!0`.
Expand Down

0 comments on commit 03d11c2

Please sign in to comment.