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

--- 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:8f6eb7077059952273cc39de66e1dca01b84cb4d

commit r17-2802-g8f6eb7077059952273cc39de66e1dca01b84cb4d
Author: Andrea Pinski <[email protected]>
Date:   Wed Jul 29 15:48:01 2026 -0700

    match: Fix `a CMP CST0 ? MIN/MAX<a, b> : MIN/MAX<a, CST1>` pattern
[PR126456]

    The order of the arguments for minmax_from_comparison is wrong for this
    pattern. I swapped the 2 CST which in some cases could cause
    incorrect code.

    Pushed as obvious after a bootstrap/testing on x86_64-linux-gnu.
    Note for backporting, minmax-29.c and minmax-30.c will need to be
    changed slightly because we don't factor out the min/max before GCC 17.

            PR tree-optimization/126456

    gcc/ChangeLog:

            * match.pd (`a CMP b ? MIN/MAX<a, c> : MIN/MAX<a, d>`): Fix
            order of minmax_from_comparison arguments.

    gcc/testsuite/ChangeLog:

            * gcc.dg/torture/minmax-1.c: New test.
            * gcc.dg/tree-ssa/minmax-29.c: New test.
            * gcc.dg/tree-ssa/minmax-30.c: New test.
            * gcc.dg/tree-ssa/minmax-31.c: New test.
            * gcc.dg/tree-ssa/minmax-32.c: New test.

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

Reply via email to