Function safe_arch::sum_of_u8_abs_diff_m128i

source ·
pub fn sum_of_u8_abs_diff_m128i(a: m128i, b: m128i) -> m128i
Available with target feature sse2 only.
Expand description

Compute “sum of u8 absolute differences”.

  • u8 lanewise abs(a - b), producing u8 intermediate values.
  • Sum the first eight and second eight values.
  • Place into the low 16 bits of two u64 lanes.
let a = m128i::from([0_u8, 11, 2, 13, 4, 15, 6, 17, 8, 19, 20, 21, 22, 23, 24, 127]);
let b = m128i::from([20_u8, 110, 250, 103, 34, 105, 60, 217, 8, 19, 210, 201, 202, 203, 204, 127]);
let c: [u64; 2] = sum_of_u8_abs_diff_m128i(a, b).into();
assert_eq!(c, [831_u64, 910]);