https://gcc.gnu.org/bugzilla/show_bug.cgi?id=106617
--- Comment #13 from CVS Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Richard Biener <rgue...@gcc.gnu.org>: https://gcc.gnu.org/g:ac68f904fe31baf80fa53218f1d8ee033bd8c79b commit r13-2113-gac68f904fe31baf80fa53218f1d8ee033bd8c79b Author: Richard Biener <rguent...@suse.de> Date: Thu Aug 18 11:10:30 2022 +0200 middle-end/106617 - fix fold_binary_op_with_conditional_arg pattern issue Now that we have parts of fold_binary_op_with_conditional_arg duplicated in match.pd and are using ! to take or throw away the result we have to be careful to not have both implementations play games which each other, causing quadratic behavior. In particular the match.pd implementation requires both arms to simplify while the fold-const.cc is happy with just one arm simplifying (something we cannot express in match.pd). The fix is to simply not enable the match.pd pattern for GENERIC. PR middle-end/106617 * match.pd ((a ? b : c) > d -> a ? (b > d) : (c > d)): Fix guard, disable on GENERIC to not cause quadratic behavior with the fold-const.cc implementation and the use of ! * gcc.dg/pr106617.c: New testcase.