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

--- Comment #11 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The releases/gcc-14 branch has been updated by Jakub Jelinek
<[email protected]>:

https://gcc.gnu.org/g:097433757515c05313a6e26d1b87cf1b5758aebc

commit r14-12748-g097433757515c05313a6e26d1b87cf1b5758aebc
Author: Jakub Jelinek <[email protected]>
Date:   Wed Jul 15 10:27:56 2026 +0200

    match.pd: Guard x+x -> x*2 simplification [PR126257]

    The x+x -> x*2 simplication obviously requires that 2 is representable
    in type, so that rules out unsigned _BitInt(1) and signed _BitInt(2)
    (and 1 too in C2Y, ditto unsigned:1 and signed:2 and :1), otherwise
    we don't multiply by 2 but by 0 or -2.
    While perhaps we could transform in those cases x+x to x<<1, I'm not
    convinced it is worth it.

    2026-07-15  Jakub Jelinek  <[email protected]>

            PR tree-optimization/126257
            * match.pd (x+x -> x*2): Only optimize if 2 is representable in the
            type.

            * gcc.dg/torture/bitint-101.c: New test.

    Reviewed-by: Richard Biener <[email protected]>
    (cherry picked from commit d5059b35e03e63c7686288c3554c2922a2c37468)

Reply via email to