Skip to content

__shift_arithmetic_rounded_saturate__

general · scripts/general/__shift_arithmetic_rounded_saturate__.m

: c = __shift_arithmetic_rounded_saturate__ (a, shift)
: c = __shift_arithmetic_rounded_saturate__ (a, b)

Arithmetic right shift with rounding and saturation (ARM64 SQSHLR).

For each element x of int32 a:

  result = saturate ((x + 2^(shift-1)) >> shift, int32)

shift is masked to 5 bits (0..31). shift == 0 returns a unchanged. When the second argument is a vector, the first element is used as the shift count (AdvSimd two-vector form).