Hacker News new | past | comments | ask | show | jobs | submit login

A big benefit comes from having branchless code. For example, if you have an if/else statement where the consequent acts on some elements of the vector and the antecedent acts on the others, you can perform them all with no branch, by taking the mask resulting from the condition for the consequent instructions, then complementing the mask and applying the antecedent to the same registers. This can also have predictable performance, because all instructions from the consequent and antecedent are executed each time, and there are no branch prediction misses to worry about. It's very useful for timing sensitive code (cryptography), and situations where you want a measurable WCET.



Masked instructions vs subsequent merging are both branchless and have no implicit data-dependent timing relative to each other.


It is possible that even masked vectorised branchless code is susceptible to side-channel attacks based on power consumption, nor would I rule out timing attacks if you can somehow get subnormal or exceptional values loaded. Is it a joy to code in this style? Perhaps. Is it a silver bullet? It is not.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: