https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110181
--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jeff Law <l...@gcc.gnu.org>: https://gcc.gnu.org/g:e08ef05e4da86d34223118092bbb857b8dd5d002 commit r16-1584-ge08ef05e4da86d34223118092bbb857b8dd5d002 Author: Sosutha Sethuramapandian <ssethuram...@marvell.com> Date: Thu Jun 19 20:53:56 2025 -0600 [PATCH] RISC-V: Use builtin clz/ctz when count_leading_zeros and count_trailing_zeros is used longlong.h for RISCV should define count_leading_zeros and count_trailing_zeros and COUNT_LEADING_ZEROS_0 when ZBB is enabled. The following patch patch fixes the bug reported in, https://gcc.gnu.org/bugzilla/show_bug.cgi?id=110181 The divdi3 on riscv32 with zbb extension generates __clz_tab instead of genearating __builtin_clzll/__builtin_clz which is not efficient since lookup table is emitted. Updating longlong.h to use this __builtin_clzll/__builtin_clz generates optimized code for the instruction. PR target/110181 include/ChangeLog * longlong.h [__riscv] (count_leading_zeros): Define. [__riscv] (count_trailing_zeros): Likewise. [__riscv] (COUNT_LEADING_ZEROS_0): Likewise.