[Bug middle-end/50481] builtin to reverse the bit order

jakub at gcc dot gnu.org gcc-bugzilla@gcc.gnu.org
Sat May 23 16:38:30 GMT 2026


https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50481

--- Comment #41 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
Though bitreverse itself needs all bits, it is just the sequence of bitreverse
+ right shift with the needed shift count that doesn't.
Though it is true that it is the case on all arches, so if it could be done in
ext_dce or somewhere else generically, then it doesn't need to be peephole2
handled on various arches.
Note, bswap actually has a similar behavior, except that it doesn't exist for
QImode and for HImode it is usually just a rotate, so most targets don't expand
it as bswapsi >> 16.  So only relevant for targets which only have bswapdi and
not bswapsi...


More information about the Gcc-bugs mailing list