To summarize: While AMD processors officially support the PDEP opcode, it is really implemented in microcode via a loop and might execute anywhere between 18-289 cycles.
This might also have potential security implications for code that performs PDEP as part of cryptographic functions that might require/rely on constant time execution (Though I'm less of an expert, maybe people like @blowdart can provide some feedback about how real this is).
In my opinion, the only proper way to handle such erratic CPU behavior (Unfortunately it's really not the last, nor the first time this sort of thing happens) is to provide HW information to developers while also making sure that the JIT can and will treat this information as a constant when it comes to code-generation.
I've already opened a separate issue for exposing these HW level constants in a more general way, but this PDEP mess also deserves some attention in its own.
The text was updated successfully, but these errors were encountered: