On 6/18/25 3:07 AM, Sosutha Sethuramapandian wrote:
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 <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.
gcc/include/ChangeLog
* longlong.h [__riscv] (count_leading_zeros): Define.
[__riscv] (count_trailing_zeros): Likewise.
[__riscv] (COUNT_LEADING_ZEROS_0): Likewise.
As someone else noted, it appears your mailer may have inserted
undesirable newlines into your patch submission. I removed those and
ran it through my tester on rv32 and rv64 successfully.
I then fixed up the ChangeLog entry and pushed this to the trunk.
Thanks!
jeff