Back to main page

Code generator for bit permutations


Back to main page


Please enter an index vector (0..31 or $0..$1f, or * for don't care):

origin base indexes refer

Options: Allow using cycles

Actual connections

This is a BPC permutation.
Routable by the Butterfly network.
Routable by the inverse Butterfly network.

Best method found: Complement permutation (about 12 cycles on superscalar processors):

x = bit_permute_step_simple(x, 0x55555555, 1);  // Bit index complement 0
x = bit_permute_step_simple(x, 0x33333333, 2);  // Bit index complement 1
x = bit_permute_step_simple(x, 0x0f0f0f0f, 4);  // Bit index complement 2

See documentation to bit_permute_step, bit_permute_step_simple, rol.
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.* which is usable for various word sizes (Pascal and C++ sources).

Error reports, comments or questions? E-mail: info@sirrida.de


You may bookmark this page as http://programming.sirrida.de?calcperm.php.
Last change: 2014-07-06