On 1/2/2026 1:15 PM, Daniel Barboza wrote:
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 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]>
I re-tested on xstormy16-elf, arc-elf and avr-elf.  Everything's happy now and after a once-over I pushed it to the trunk after fixing a few whitespace nits in the ChangeLog the pre-commit hooks complained about.

jeff

Reply via email to