https://gcc.gnu.org/bugzilla/show_bug.cgi?id=102134
--- Comment #10 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Roger Sayle <sa...@gcc.gnu.org>: https://gcc.gnu.org/g:74cb45e67d14624c3e2fafa99a8920d1866a5f0c commit r12-3372-g74cb45e67d14624c3e2fafa99a8920d1866a5f0c Author: Roger Sayle <ro...@nextmovesoftware.com> Date: Mon Sep 6 22:48:53 2021 +0100 Correct implementation of wi::clz As diagnosed with Jakub and Richard in the analysis of PR 102134, the current implementation of wi::clz has incorrect/inconsistent behaviour. As mentioned by Richard in comment #7, clz should (always) return zero for negative values, but the current implementation can only return 0 when precision is a multiple of HOST_BITS_PER_WIDE_INT. The fix is simply to reorder/shuffle the existing tests. 2021-09-06 Roger Sayle <ro...@nextmovesoftware.com> gcc/ChangeLog * wide-int.cc (wi::clz): Reorder tests to ensure the result is zero for all negative values.