https://gcc.gnu.org/bugzilla/show_bug.cgi?id=122608
--- Comment #6 from GCC Commits <cvs-commit at gcc dot gnu.org> --- The master branch has been updated by Jeff Law <[email protected]>: https://gcc.gnu.org/g:b01d6fa9759a4802fcc34c89f95a2f4b92724608 commit r16-6484-gb01d6fa9759a4802fcc34c89f95a2f4b92724608 Author: Daniel Barboza <[email protected]> Date: Sun Jan 4 10:44:51 2026 -0700 [PATCH v4] match.pd: (c?a:b) op d -> c ? (a op d):(b op d) [PR122608] Add a pattern to handle cases where we have an OP that is unconditionally being applied in the result of a gcond. In this case we can apply OP to both legs of the conditional. E.g: t = b ? 10 : 20; t = t + 20; becomes just: t = b ? 30 : 40 A variant pattern was also added to handle the case where the gcond result is used as the second operand. This was needed because most of the ops we're handling aren't commutative. PR tree-optimization/122608 gcc/ChangeLog: * match.pd (`(c ? a : b) op d -> c ? (a op d) : (b op d)`): New pattern. (`d op (c ? a : b) -> c ? (d op a) : (d op b)`): Likewise gcc/testsuite/ChangeLog: * gcc.target/i386/pr110701.c: the pattern added is now folding an XOR into the ifcond and the assembler isn't emitting an 'andl' anymore. The test was turned into a runtime test instead. * gcc.dg/torture/pr122608.c: New test. Signed-off-by: Daniel Barboza <[email protected]>
