> simply add 128 (or however much—depending on the sizes at hand) to each of your inputs before comparing On many CPUs, bitwise XOR is slightly more efficient than addition. But you still need the magic number. > and you are in a hostile environment, you will have to figure out how to load up a vector of 128s, which costs cycles That particular vector can be generated with 2 instructions without RAM access, pcmpeqd t…
Yep, some constants are better to be generated than loaded, see the docs from Mr. Agner. On a more global scale, all assembly "optimisations"/tricks are hidden deep into compilers, which are reasonably "transparent" to their devs only, that due to their abysmal complexity and size. We would need some sort of online library for those assembly (boolean/branchless calculus...) tricks. A job for wikipedia? Maybe linked t…
Couple times I even back-ported these tricks from clang-generated assembly back into C++ intrinsics.