Skip to content

Commit 3edb521

Browse files
committed
simd_bitmask intrinsic: add a non-power-of-2 multi-byte example
1 parent a451b2a commit 3edb521

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

core/src/intrinsics/simd.rs

+13-6
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ extern "rust-intrinsic" {
463463
/// `T` must be an integer vector.
464464
///
465465
/// `U` must be either the smallest unsigned integer with at least as many bits as the length
466-
/// of `T`, or the smallest array of `u8` with as many bits as the length of `T`.
466+
/// of `T`, or the smallest array of `u8` with at least as many bits as the length of `T`.
467467
///
468468
/// Each element is truncated to a single bit and packed into the result.
469469
///
@@ -475,12 +475,19 @@ extern "rust-intrinsic" {
475475
/// * On little endian, the least significant bit corresponds to the first vector element.
476476
/// * On big endian, the least significant bit corresponds to the last vector element.
477477
///
478-
/// For example, `[!0, 0, !0, !0]` packs to `0b1101` on little endian and `0b1011` on big
479-
/// endian.
478+
/// For example, `[!0, 0, !0, !0]` packs to
479+
/// - `0b1101u8` or `[0b1101]` on little endian, and
480+
/// - `0b1011u8` or `[0b1011]` on big endian.
480481
///
481-
/// To consider a larger example, `[!0, 0, 0, 0, 0, 0, 0, 0, !0, !0, 0, 0, 0, 0, !0, 0]` packs
482-
/// to `[0b00000001, 0b01000011]` or `0b0100001100000001` on little endian, and `[0b10000000,
483-
/// 0b11000010]` or `0b1000000011000010` on big endian.
482+
/// To consider a larger example,
483+
/// `[!0, 0, 0, 0, 0, 0, 0, 0, !0, !0, 0, 0, 0, 0, !0, 0]` packs to
484+
/// - `0b0100001100000001u16` or `[0b00000001, 0b01000011]` on little endian, and
485+
/// - `0b1000000011000010u16` or `[0b10000000, 0b11000010]` on big endian.
486+
///
487+
/// And finally, a non-power-of-2 example with multiple bytes:
488+
/// `[!0, !0, 0, !0, 0, 0, !0, 0, !0, 0]` packs to
489+
/// - `0b0101001011u16` or `[0b01001011, 0b01]` on little endian, and
490+
/// - `0b1101001010u16` or `[0b11, 0b01001010]` on big endian.
484491
///
485492
/// # Safety
486493
/// `x` must contain only `0` and `!0`.

0 commit comments

Comments
 (0)