https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106677
--- Comment #6 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The trunk branch has been updated by Andrew Pinski <pins...@gcc.gnu.org>: https://gcc.gnu.org/g:d9a0d692ffc6951c5670f54c3f4f17ec64a58600 commit r14-3486-gd9a0d692ffc6951c5670f54c3f4f17ec64a58600 Author: Andrew Pinski <apin...@marvell.com> Date: Sat Aug 19 15:30:45 2023 -0700 MATCH: Move `a ? one_zero : one_zero` matching after min/max matching In PR 106677, I noticed that on the trunk we were producing: ``` _25 = SR.116_117 == 0; _27 = (unsigned char) _25; _32 = _27 | SR.116_117; ``` From `SR.115_117 != 0 ? SR.115_117 : 1` Rather than: ``` _119 = MAX_EXPR <1, SR.115_117>; ``` Or (rather) ``` _119 = SR.115_117 | 1; ``` Due to the order of the patterns. Committed as approved with the new comment and testcase. Bootstrapped and tested on x86_64-linux-gnu with no regressions. gcc/ChangeLog: * match.pd (`a ? one_zero : one_zero`): Move below detection of minmax. gcc/testsuite/ChangeLog: * gcc.dg/tree-ssa/phi-opt-34.c: New test.