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

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

https://gcc.gnu.org/g:610f1166538ad2e637c913be78b074100270cc5c

commit r17-3234-g610f1166538ad2e637c913be78b074100270cc5c
Author: Andrea Pinski <[email protected]>
Date:   Mon Jul 27 20:11:33 2026 -0700

    match: Fix recent pattern for signed integer overflow dealing with -
[PR126418]

    A recent match patterns were added that introduce signed integer overflow
where
    there was none before.  `cmp + (-cmp ^ x)` has no signed integer overflow
when
    x is INT_MIN when cmp is 0. This gets translated into cmp ? -x : x.
    But this has now introduced an signed integer overflow for INT_MIN.
    The fix is to use unsigned type for the negative.

    Bootstrapped and tested on x86_64-linux-gnu.

    Changes since v1:
    * v2: Remove the abs patterns since a signed integer overflow would have
happened anyways.

            PR tree-optimization/126418

    gcc/ChangeLog:

            * match.pd (`(A ^ -cmp) + cmp`): Cast to unsigned type
            before taking the negative.

    gcc/testsuite/ChangeLog:

            * gcc.dg/tree-ssa/pr126418-1.c: New test.

    Signed-off-by: Andrea Pinski <[email protected]>

Reply via email to