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

--- Comment #7 from GCC Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jakub Jelinek <ja...@gcc.gnu.org>:

https://gcc.gnu.org/g:24aa051af7c59f37ec45aea754b48b97d210ea6d

commit r14-9175-g24aa051af7c59f37ec45aea754b48b97d210ea6d
Author: Jakub Jelinek <ja...@redhat.com>
Date:   Mon Feb 26 10:08:45 2024 +0100

    match.pd: Guard 2 simplifications on integral TYPE_OVERFLOW_UNDEFINED
[PR114090]

    These 2 patterns are incorrect on floating point, or for -fwrapv, or
    for -ftrapv, or the first one for unsigned types (the second one is
    mathematically correct, but we ought to just fold that to 0 instead).

    So, the following patch properly guards this.

    I think we don't need && !TYPE_OVERFLOW_SANITIZED (type) because
    in both simplifications there would be UB before and after on
    signed integer minimum.

    2024-02-26  Jakub Jelinek  <ja...@redhat.com>

            PR tree-optimization/114090
            * match.pd ((x >= 0 ? x : 0) + (x <= 0 ? -x : 0) -> abs x):
            Restrict pattern to ANY_INTEGRAL_TYPE_P and TYPE_OVERFLOW_UNDEFINED
            types.
            ((x <= 0 ? -x : 0) -> max(-x, 0)): Likewise.

            * gcc.dg/pr114090.c: New test.

Reply via email to