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

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

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

commit r16-4729-gc45a8fb11ae0c57bca052765742df6c8ad91f164
Author: Uros Bizjak <[email protected]>
Date:   Thu Oct 30 08:59:32 2025 +0100

    386: Make better use of overflow flags in codegen of min/max(a,add/sub(a,
b)) [PR116815]

    Fold the following patterns:
    - umax (a, add (a, b)) -> [sum,  ovf] = add (a, b); ovf ? a : sum
    - umin (a, add (a, b)) -> [sum,  ovf] = add (a, b); ovf ? sum : a
    - umax (a, sub (a, b)) -> [diff, udf] = sub (a, b); udf ? diff : a
    - umin (a, sub (a, b)) -> [diff, udf] = sub (a, b); udf ? a : diff

    Where ovf/udf is the carry flag that represents overflow in case of
    add and underflow in case of sub.

    Co-developed-by: Dhruv Chawla <[email protected]>

            PR target/116815

    gcc/ChangeLog:

            * config/i386/i386.md (ovf_add_cmp): New code attribute.
            (udf_sub_cmp): Ditto.
            (ovf_comm): New int iterator.
            (*plus_within_<code><mode>3_<ovf_comm>): New insn and split
pattern.
            (*minus_within_<code><mode>3): Ditto.

    gcc/testsuite/ChangeLog:

            * gcc.dg/pr116815.c: New test.
            * gcc.target/i386/pr116815.c: New test.

Reply via email to