_mm256_maskz_ternarylogic_epi32
Classification
AVX-512, Logical, CPUID Test: AVX512F
Header File
Instruction
VPTERNLOGD ymm {z}, ymm, ymm, imm8
Synopsis
_mm256_maskz_ternarylogic_epi32(__mmask8 k, __m256i a, __m256i b, __m256i 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 32-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 zeromask "k" at 32-bit granularity (32-bit elements are zeroed out 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*32
IF k[j]
FOR h := 0 to 31
dst[i+h] := TernaryOP(imm8[7:0], a[i+h], b[i+h], c[i+h])
ENDFOR
ELSE
dst[i+31:i] := 0
FI
ENDFOR
dst[MAX:256] := 0