_mm_ternarylogic_epi64
Classification
AVX-512, Logical, CPUID Test: AVX512F
Header File
Instruction
VPTERNLOGQ xmm, xmm, xmm, imm8
Synopsis
_mm_ternarylogic_epi64(__m128i a, __m128i b, __m128i 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".
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 1
i := j*64
FOR h := 0 to 63
dst[i+h] := TernaryOP(imm8[7:0], a[i+h], b[i+h], c[i+h])
ENDFOR
ENDFOR
dst[MAX:128] := 0