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

Best method found: Bit group moving (about 39 cycles on superscalar processors):

x = (x & 0x00000080)
| ((x & 0x01000000) << 1)
| rol(x & 0x10800000, 4)
| ((x & 0x00000444) << 6)
| ((x & 0x00002000) << 7)
| ((x & 0x00010000) << 8)
| ((x & 0x00004020) << 9)
| ((x & 0x00000011) << 11)
| ((x & 0x00200000) >> 19)
| ((x & 0x04000000) >> 17)
| ((x & 0x20040000) >> 12)
| rol(x & 0x00008100, 21)
| ((x & 0x00000200) << 22)
| ((x & 0x00400000) >> 9)
| ((x & 0x00000800) >> 8)
| ((x & 0x00021000) >> 7)
| rol(x & 0x08000002, 27)
| ((x & 0x42000000) >> 4)
| ((x & 0x00000008) >> 2)
| ((x & 0x80180000) >> 1);

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.
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:
info@sirrida.de

You may
bookmark
this page as
http://programming.sirrida.de?calcperm.php.

Last change: 2015-11-10