]> gcc.gnu.org Git - gcc.git/commit
Fix PR 111331: wrong code for `a > 28 ? MIN<a, 28> : 29`
authorAndrew Pinski <apinski@marvell.com>
Fri, 8 Sep 2023 05:13:31 +0000 (22:13 -0700)
committerAndrew Pinski <quic_apinski@quicinc.com>
Wed, 8 May 2024 16:27:46 +0000 (09:27 -0700)
commit16e27b6d03756bf1fae22607fa93107787a7b9cb
tree92af7454c628569cac940e76fb7eed55b6ae01e6
parent6c00c3245e688d00dae3e928f0d03f530640caae
Fix PR 111331: wrong code for `a > 28 ? MIN<a, 28> : 29`

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.

Committed to GCC 13 branch after bootstrapped and tested on x86_64-linux-gnu.

gcc/ChangeLog:

PR tree-optimization/111331
* tree-ssa-phiopt.c (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.

(cherry picked from commit 30e6ee074588bacefd2dfe745b188bb20c81fe5e)
gcc/testsuite/gcc.c-torture/execute/pr111331-1.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/pr111331-2.c [new file with mode: 0644]
gcc/testsuite/gcc.c-torture/execute/pr111331-3.c [new file with mode: 0644]
gcc/tree-ssa-phiopt.c
This page took 0.059388 seconds and 6 git commands to generate.