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

--- Comment #15 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>:

https://gcc.gnu.org/g:059fdb725ba8210a88a2416a1f819b9ba5453095

commit r15-4870-g059fdb725ba8210a88a2416a1f819b9ba5453095
Author: Andrew Pinski <quic_apin...@quicinc.com>
Date:   Wed Oct 30 21:10:19 2024 -0700

    match: Fix `a != 0 ? a - 1 : 0` pattern [PR117363]

    There are a couple of things wrong with this pattern which
    I missed during the review. First each nop_convert should
    be nop_convert1 or nop_convert2.
    Second is we need to the minus in the same type as the minus
    was originally so we don't introduce extra undefined behavior
    (signed integer overflow). And we need a convert into the new
    type too.

    pr117363-1.c tests not introducing extra undefined behavior.
    pr117363-2.c tests the casting to the correct final type, ldist
    introduces the cond_expr here.

    Bootstraped and tested on x86_64-linux-gnu.

            PR tree-optimization/117363

    gcc/ChangeLog:

            * match.pd (`a != 0 ? a - 1 : 0`): Fix type handling
            and nop_convert handling.

    gcc/testsuite/ChangeLog:

            * gcc.dg/torture/pr117363-1.c: New test.
            * gcc.dg/torture/pr117363-2.c: New test.

    Signed-off-by: Andrew Pinski <quic_apin...@quicinc.com>

Reply via email to