https://gcc.gnu.org/bugzilla/show_bug.cgi?id=50481
--- Comment #16 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jakub Jelinek <[email protected]>: https://gcc.gnu.org/g:c564a8be8a15389e8a5119e51d5929f0689044be commit r17-523-gc564a8be8a15389e8a5119e51d5929f0689044be Author: Jakub Jelinek <[email protected]> Date: Fri May 15 09:50:52 2026 +0200 Add __builtin_bitreverse{8,16,32,64} builtins [PR50481] Future work could optimize this on specific targets: - ARM: lower to RBIT - x86 with GFNI: lower to vgf2p8affineqb https://wunkolo.github.io/post/2020/11/gf2p8affineqb-bit-reversal/ 2026-05-15 Disservin <[email protected]> Jakub Jelinek <[email protected]> PR target/50481 * builtin-types.def (BT_FN_UINT8_UINT8): New. * builtins.def (BUILT_IN_BITREVERSE8, BUILT_IN_BITREVERSE16, BUILT_IN_BITREVERSE32, BUILT_IN_BITREVERSE64): New builtins. * builtins.cc (expand_builtin, is_inexpensive_builtin): Handle bitreverse builtins. * fold-const-call.cc (fold_const_call_ss): Fold bitreverse builtins. * fold-const.cc (tree_call_nonnegative_warnv_p): Handle bitreverse builtins. * optabs.def (bitreverse_optab): New. * optabs.cc (expand_bitreverse): New function. (expand_unop): Use it for bitreverse_optab. * tree-ssa-ccp.cc (evaluate_stmt): Handle bitreverse builtins. * tree-ssa-phiopt.cc (empty_bb_or_one_feeding_into_p, cond_removal_in_builtin_zero_pattern): Likewise. * doc/extend.texi: Document __builtin_bitreverse{8,16,32,64}. * doc/md.texi (bitreverse<mode>2): Document. * gcc.dg/builtin-bitreverse-1.c: New test. * gcc.dg/builtin-bitreverse-2.c: New test. Signed-off-by: Disservin <[email protected]>
