Skip to content

Commit 03d11c2

Browse files
committed
Auto merge of rust-lang#126171 - RalfJung:simd_bitmask_multibyte, r=workingjubilee
simd_bitmask intrinsic: add a non-power-of-2 multi-byte example r? `@calebzulawski` `@workingjubilee`
2 parents de4f5c2 + 3edb521 commit 03d11c2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

Diff for: core/src/intrinsics/simd.rs

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

0 commit comments

Comments
 (0)