I am writing an LLVM pass module to instrument every single memory operation in a program, and part of my logic needs to do some very hot binary logic on pointers.
How can I implement "bit ? u64_value : zero" in as few cycles as possible, preferably without using an explicit branch? I have a bit in the least significant bit of a register, and a value (assume u64) in another. If the bit is set, i want the value preserved. If the bit is zero, I want to zero out the register.
I can use x86 BMI instructions.