This is a BPC permutation.
Best method found: BP permutation (about 5 cycles on superscalar processors):
x = bit_permute_step(x, 0x0c0c0c0c, 2); // Bit index swap 1,2
See documentation to
pext and pdep can be emulated with compress_right and expand_right.
This result is not necessarily the best possible, but at least several methods have been challenged.
See also some notes on the inner workings.
There is an even better calculator calcperm.* usable for various bit depths as Pascal and C++ sources.
Error reports, comments or questions? E-mail: firstname.lastname@example.org