_mm_mask_gf2p8mul_epi8
Classification
Other, Arithmetic, CPUID Test: GFNI
Header File
Instruction
VGF2P8MULB xmm {k}, xmm, xmm
Synopsis
_mm_mask_gf2p8mul_epi8(__m128i src, __mmask16 k, __m128i a, __m128i b);
Description
Multiply the packed 8-bit integers in "a" and "b" in the finite field GF(2^8), and store the results in "dst" using writemask "k" (elements are copied from "src"" when the corresponding mask bit is not set). The field GF(2^8) is represented in polynomial representation with the reduction polynomial x^8 + x^4 + x^3 + x + 1.
Operation
DEFINE gf2p8mul_byte(src1byte, src2byte) {
tword := 0
FOR i := 0 to 7
IF src2byte.bit[i]
tword := tword XOR (src1byte << i)
FI
ENDFOR
FOR i := 14 downto 8
p := 0x11B << (i-8)
IF tword.bit[i]
tword := tword XOR p
FI
ENDFOR
RETURN tword.byte[0]
}
FOR j := 0 TO 15
IF k[j]
dst.byte[j] := gf2p8mul_byte(a.byte[j], b.byte[j])
ELSE
dst.byte[j] := src.byte[j]
FI
ENDFOR
dst[MAX:128] := 0