An Innocuous Blog Post about vPMU in QEMU
vulpinecitrus.info3 pointsby mmozeiko0 comments
tmp = (a ^ b) & mask
a ^= tmp
b ^= tmp
If mask = 0xfff...fff then a/b will be swapped, otherwise if mask = 0 then they'll remain the same. (NOT A) OR ((NOT B) XOR (C AND A))
then you simply write ~_MM_TERNLOG_A | (~_MM_TERNLOG_B ^ (_MM_TERNLOG_C & _MM_TERNLOG_A))
Literally the expression you want to calculate. It evaluates to immediate from _MM_TERNLOG_A/B/C constants defined in intrinsic headers, at least for gcc & clang: typedef enum {
_MM_TERNLOG_A = 0xF0,
_MM_TERNLOG_B = 0xCC,
_MM_TERNLOG_C = 0xAA
} _MM_TERNLOG_ENUM;
For MSVC you define them yourself. #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.
Here's html version: https://zzqcn.github.io/perf/intel_opt_manual/3.html#clearin...
AMD has similar list in "2.9.2 Idioms for Dependency removal" from "Software Optimization Guide for the AMD Zen5 Microarchitecture" document: https://docs.amd.com/v/u/en-US/58455_1.00