[PATCH v2 1/1] Match: optimize `a == CST & unary(a)` [PR111487]

Andrew Pinski via Sourceware Forge forge-bot@forge-test.rdfm.org
Tue Sep 30 19:01:47 GMT 2025


From: Andrew Pinski <andrew.pinski@oss.qualcomm.com>

This is an expansion of the optimize `a == CST & a`
to handle more than just casts. It adds optimization
for unary<a>.
The patch for binary operators will come later.

Bootstrapped and tested on x86_64-linux-gnu with no regressions.

	PR tree-optimization/111487
gcc/ChangeLog:

	* match.pd (tcc_int_unary): New operator list.
	(`a == CST & unary(a)`): New pattern.

gcc/testsuite/ChangeLog:

	* gcc.dg/tree-ssa/and-unary-1.c: New test.

Signed-off-by: Andrew Pinski <andrew.pinski@oss.qualcomm.com>
---
 gcc/match.pd                                | 12 ++++
 gcc/testsuite/gcc.dg/tree-ssa/and-unary-1.c | 61 +++++++++++++++++++++
 2 files changed, 73 insertions(+)
 create mode 100644 gcc/testsuite/gcc.dg/tree-ssa/and-unary-1.c

-------------- next part --------------
A non-text attachment was scrubbed...
Name: v2-0001-Match-optimize-a-CST-unary-a-PR111487.patch
Type: text/x-patch
Size: 2899 bytes
Desc: not available
URL: <https://sourceware.org/pipermail/test-list/attachments/20250930/50fde289/attachment-0001.bin>


More information about the Test-list mailing list