> * VPTERNLOGD (your swiss army railgun for bitwise logic, can often fuse 2 or even 3 ops into one)
I wonder if this would be useful for implementing cryptographic algorithms.
I wonder if this would be useful for implementing cryptographic algorithms.
VPTERNLOGD basically works by constructing a truth table for 3 inputs.
| A | B | C | R
| 0 | 0 | 0 | x
| 0 | 0 | 1 | x
| 0 | 1 | 0 | x
| 0 | 1 | 1 | x
| 1 | 0 | 0 | x
| 1 | 0 | 1 | x
| 1 | 1 | 0 | x
| 1 | 1 | 1 | x
You pick the values you want for R, then pass this 8-bit value as the operand to the instruction along with the 3 values.For example, A ∧ B ∧ C would be 0b10000000. A ∧ ¬B ∧ ¬C would be 0xb00010000
There are 256 such tables and many of them can be represented by multiple boolean expressions.
#define A 0xf0
#define B 0xcc
#define C 0xaa
And then you can build immediate for VPTERNLOG operation by writing bitwise expression with A/B/C values in source code.For example, A^B^C=150. A^(~B&C)=210. And so on...
Also mentioned by Fabian here: https://twitter.com/rygorous/status/1187032693944410114