_mm256_mpsadbw_epu8
Classification
AVX_ALL, Miscellaneous, CPUID Test: AVX2
Header File
Instruction
VMPSADBW ymm, ymm, ymm, imm8
Synopsis
_mm256_mpsadbw_epu8(__m256i a, __m256i b, const int imm8);
Description
Compute the sum of absolute differences (SADs) of quadruplets of unsigned 8-bit integers in "a" compared to those in "b", and store the 16-bit results in "dst".
Eight SADs are performed for each 128-bit lane using one quadruplet from "b" and eight quadruplets from "a". One quadruplet is selected from "b" starting at on the offset specified in "imm8". Eight quadruplets are formed from sequential 8-bit integers selected from "a" starting at the offset specified in "imm8".
Operation
DEFINE MPSADBW(a[127:0], b[127:0], imm8[2:0]) {
a_offset := imm8[2]*32
b_offset := imm8[1:0]*32
FOR j := 0 to 7
i := j*8
k := a_offset+i
l := b_offset
tmp[i*2+15:i*2] := ABS(Signed(a[k+7:k] - b[l+7:l])) + ABS(Signed(a[k+15:k+8] - b[l+15:l+8])) + \
ABS(Signed(a[k+23:k+16] - b[l+23:l+16])) + ABS(Signed(a[k+31:k+24] - b[l+31:l+24]))
ENDFOR
RETURN tmp[127:0]
}
dst[127:0] := MPSADBW(a[127:0], b[127:0], imm8[2:0])
dst[255:128] := MPSADBW(a[255:128], b[255:128], imm8[5:3])
dst[MAX:256] := 0