This patch proposes adding run-time library support for bit reversal, by adding a __bitrevsi2 function to libgcc. Thoughts/opinions? I'm also tempted to add __popcount[qh]i2 and __parity[qh]i2 to libgcc, to allow the RTL optimizers to perform narrowing operations, but I'm curious to hear whether QImode and HImode support, though more efficient, is frowned by the libgcc maintainers/philosophy. This patch has been tested on x86_64-pc-linux-gnu with make bootstrap and make -k check, both with and without --target_board=unix{-m32} and on nvptx-none, with no new regressions. Ok for mainline? 2023-05-06 Roger Sayle gcc/ChangeLog * doc/libgcc.texi (__bitrevqi2): Document bit reversal run-time functions; __bitrevqi2, __bitrevhi2, __bitrevsi2 and __bitrevdi2. libgcc/ChangeLog * Makfile.in (lib2funcs): Add __bitrev[qhsd]i2. * libgcc-std.ver.in (GCC_14.0.0): Add __bitrev[qhsd]i2. * libgcc2.c (__bitrevqi2): New function. (__bitrevhi2): Likewise. (__bitrevsi2): Likewise. (__bitrevdi2): Likewise. * libgcc2.h (__bitrevqi2): Prototype here. (__bitrevhi2): Likewise. (__bitrevsi2): Likewise. (__bitrevdi2): Likewise. Thanks in advance, Roger --