This is a BPC permutation.
Routable by the Butterfly network.
Best method found: BP permutation (about 15 cycles on superscalar processors):
x = bit_permute_step(x, 0x00aa00aa, 7); // Bit index swap 0,3 x = bit_permute_step(x, 0x00cc00cc, 6); // Bit index swap 1,3 x = bit_permute_step(x, 0x00f000f0, 4); // Bit index swap 2,3
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. The given cycles are only estimated and may vary significantly depending on the used processor. Thus, the selected method might not be the best one for your application. You can however influence the choice by using the options above.
See also some notes on the inner workings.
There is an even better calculator calcperm.* which is usable for various word sizes (Pascal and C++ sources).
Error reports, comments or questions? E-mail: firstname.lastname@example.org