[Bug middle-end/126625] hwint.cc reflect_hwi () should use __builtin_bitreverse64 if supported.

"cvs-commit at gcc dot gnu.org via Gcc-bugs" <[email protected]>
Newsgroups gmane.comp.gcc.bugs
Message-ID <[email protected]/bugzilla/>
https://gcc.gnu.org/bugzilla/show_bug.cgi?id=126625

--- Comment #4 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Kael Andrew Franco <[email protected]>:

https://gcc.gnu.org/g:c73b71d6bc7e106714bec94d13f877c6027d9531

commit r17-3165-gc73b71d6bc7e106714bec94d13f877c6027d9531
Author: Kael Andrew Alonzo Franco <[email protected]>
Date:   Sat Aug 8 21:59:24 2026 -0400

    middle-end: If supported, use __builtin_*. [PR126625]

    hwint.cc reflect_hwi uses a naive for loop approach to
    emulate __builtin_bitreverse64 ().
    This is slow compared to using __builtin_bitreverse64 () plus bitshift.
    This is useful for bootstrapping GCC since r17-523.
    Also add assert on BITWIDTH <= 64.

    For reflect_hwi and ira-color.cc, add STAGE0_CXX_HAS_BUILTIN
    in system.h to test for specific builtins.

    Bootstrapped and regtested on x86_64-pc-linux-gnu.

            PR middle-end/126625

    gcc/ChangeLog:

            * hwint.cc (reflect_hwi): Use STAGE0_CXX_HAS_BUILTIN
            for __builtin_bitreverse64.
            * ira-color.cc (HAS_SMUL_OVERFLOW): Remove
            and use STAGE0_CXX_HAS_BUILTIN instead.
            * system.h (STAGE0_CXX_HAS_BUILTIN): New macro.

    Signed-off-by: Kael Andrew Franco <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.