_mm512_mask_ternarylogic_epi64
Classification
AVX-512, Logical, CPUID Test: AVX512F
Header File
immintrin.h
Instruction
VPTERNLOGQ zmm {k}, zmm, zmm, imm8
Synopsis
 _mm512_mask_ternarylogic_epi64(__m512i a, __mmask8 k, __m512i b, __m512i c, int imm8);
Description
Bitwise ternary logic that provides the capability to implement any three-operand binary function; the specific binary function is specified by value in "imm8". For each bit in each packed 64-bit integer, the corresponding bit from "a", "b", and "c" are used according to "imm8", and the result is written to the corresponding bit in "dst" using writemask "k" at 64-bit granularity (64-bit elements are copied from "a" when the corresponding mask bit is not set).
Operation
DEFINE TernaryOP(imm8, a, b, c) {
	CASE imm8[7:0] OF
	0: dst[0] := 0                   // imm8[7:0] := 0
	1: dst[0] := NOT (a OR b OR c)   // imm8[7:0] := NOT (_MM_TERNLOG_A OR _MM_TERNLOG_B OR _MM_TERNLOG_C)
	// ...
	254: dst[0] := a OR b OR c       // imm8[7:0] := _MM_TERNLOG_A OR _MM_TERNLOG_B OR _MM_TERNLOG_C
	255: dst[0] := 1                 // imm8[7:0] := 1
	ESAC
}
imm8[7:0] = LogicExp(_MM_TERNLOG_A, _MM_TERNLOG_B, _MM_TERNLOG_C)
FOR j := 0 to 7
	i := j*64
	IF k[j]
		FOR h := 0 to 63
			dst[i+h] := TernaryOP(imm8[7:0], a[i+h], b[i+h], c[i+h])
		ENDFOR
	ELSE
		dst[i+63:i] := src[i+63:i]
	FI
ENDFOR
dst[MAX:512] := 0