https://gcc.gnu.org/bugzilla/show_bug.cgi?id=125517

--- Comment #4 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:96ce4939706066bccad5da441c9a96ae5c3fbcb0

commit r17-1161-g96ce4939706066bccad5da441c9a96ae5c3fbcb0
Author: Jakub Jelinek <[email protected]>
Date:   Tue Jun 2 08:52:44 2026 +0200

    wide-int: Fix up wi::bitreverse_large [PR125517]

    The following testcase shows wi::bitreverse_large is buggy.  In particular,
    it uses the len argument (i.e. number of limbs the xval wide_int has)
    to decide how much to clear, but it should be using BLOCKS_NEEDED
    (precision) for that and for canonize argument similarly to
wi::bswap_large,
    because it behaves similarly to that.  If xval is say len 1 but precision
    512, we want to clear all 512 bits in the result limbs and the loop then
    sets the most significant one in there and canonize with len (512 + 63) /
    64, not initialize just the least significant limb, set various bits in the
    uninitialized ones and then only care about the least significant 64 bits
    anyway.

    2026-06-02  Jakub Jelinek  <[email protected]>

            PR middle-end/125517
            * wide-int.cc (wi::bitreverse_large): Rename LEN argument to XLEN
and
            use it as safe_uhwi argument.  Add LEN automatic variable set to
            BLOCKS_NEEDED (precision).  Replace loop clearing val with memset.
            Remove I automatic variable.

            * gcc.dg/builtin-bitreverse-9.c: New test.

    Reviewed-by: Andrew Pinski <[email protected]>

Reply via email to