-
Notifications
You must be signed in to change notification settings - Fork 13.7k
Description
Feature gate: #![feature(funnel_shifts)]
This is a tracking issue for implementation of funnel shifts on integers.
Funnel shifts are essentially a generalization of bitwise rotations. a.funnel_shl(b, n)
means concatenate a
and b
(with a
in the most significant half), creating an integer twice as wide, shifting this to the left by n
(taken modulo the bit size of a
and b
), shifting in zeros, and finally extract the most significant half of the wide integer as the result.
The functions will panic if n >= T::BITS
, and the wrapping
versions consider n
modulo T::BITS
. The unchecked
variant doesn't do any checks (as the name suggests), and so is unsafe.
a.wrapping_funnel_shl(a, n)
is meant to be exactly equivalent to a.rotate_left(n)
.
Public API
funnel_shl
andfunnel_shr
(and theirwrapping
andunchecked
variants) on the primitive integer typesu8
,u16
,u32
,u64
andu128
Steps / History
A SIMD version of these intrinsics were added in #142078
- Implementation
- Final comment period (FCP)1
- Stabilization PR
Unresolved Questions
- Should we also provide these functions on signed integer types (akin to
rotate
s)?