On 9/8/23 06:39, Andrew Pinski via Gcc-patches wrote:
The problem here is after r6-7425-ga9fee7cdc3c62d0e51730,
the comparison to see if the transformation could be done was using the
wrong value. Instead of see if the inner was LE (for MIN and GE for MAX)
the outer value, it was comparing the inner to the value used in the comparison
which was wrong.
The match pattern copied the same logic mistake when they were added in
r14-1411-g17cca3c43e2f49 .

OK? Bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

        PR tree-optimization/111331
        * match.pd (`(a CMP CST1) ? max<a,CST2> : a`):
        Fix the LE/GE comparison to the correct value.
        * tree-ssa-phiopt.cc (minmax_replacement):
        Fix the LE/GE comparison for the
        `(a CMP CST1) ? max<a,CST2> : a` optimization.

gcc/testsuite/ChangeLog:

        PR tree-optimization/111331
        * gcc.c-torture/execute/pr111331-1.c: New test.
        * gcc.c-torture/execute/pr111331-2.c: New test.
        * gcc.c-torture/execute/pr111331-3.c: New test.
OK
jeff

Reply via email to