]> git.ipfire.org Git - thirdparty/gcc.git/commit
match: Improve `(a != b) ? (a + b) : (2 * a)` pattern [PR19832]
authorAndrew Pinski <quic_apinski@quicinc.com>
Sun, 24 Dec 2023 23:51:35 +0000 (15:51 -0800)
committerAndrew Pinski <quic_apinski@quicinc.com>
Mon, 25 Dec 2023 04:01:32 +0000 (20:01 -0800)
commit59ecd5ff096f800de17b804f1482055f2d84d629
tree986d00ae3ea2571edf47980aefdb7af18e025c4a
parentf0269df25af37097a06ae247a18c71e24aa32e3e
match: Improve `(a != b) ? (a + b) : (2 * a)` pattern [PR19832]

In the testcase provided, we would match f_plus but not g_plus
due to a missing `:c` on the plus operator. This fixes the oversight
there.

Note this was noted in https://github.com/llvm/llvm-project/issues/76318 .

Committed as obvious after bootstrap/test on x86_64-linux-gnu.

PR tree-optimization/19832

gcc/ChangeLog:

* match.pd (`(a != b) ? (a + b) : (2 * a)`): Add `:c`
on the plus operator.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/phi-opt-same-2.c: New test.

Signed-off-by: Andrew Pinski <quic_apinski@quicinc.com>
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/phi-opt-same-2.c [new file with mode: 0644]