]> git.ipfire.org Git - thirdparty/gcc.git/commit
MATCH: remove negate for 1bit types
authorAndrew Pinski <apinski@marvell.com>
Wed, 23 Aug 2023 01:41:56 +0000 (18:41 -0700)
committerAndrew Pinski <apinski@marvell.com>
Thu, 24 Aug 2023 06:52:25 +0000 (23:52 -0700)
commitddd64a6ec3b38e18aefb9fcba50c0d9297e5e711
treeac4cf56bde5bfabf623576c3289dcc91a86f995b
parent7e05cd632fab458717af4d4431c9f7e43ad062ad
MATCH: remove negate for 1bit types

For 1bit types, negate is either undefined or don't change the value.
In either cases we want to remove them.
This patch adds a match pattern to do that.
Also converting to a 1bit type we can remove the negate just like we already do
for `&1` so this patch adds that too.

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

Notes on the testcases:
This patch is the last part to fix PR 95929; cond-bool-2.c testcase.
bit1neg-1.c is a 1bit-field testcase where we could remove the assignment
all the way in one case (which happened on the RTL level for some targets but not all).
cond-bool-2.c is the reduced testcase of PR 95929.

PR tree-optimization/95929

gcc/ChangeLog:

* match.pd (convert?(-a)): New pattern
for 1bit integer types.

gcc/testsuite/ChangeLog:

* gcc.dg/tree-ssa/bit1neg-1.c: New test.
* gcc.dg/tree-ssa/cond-bool-1.c: New test.
* gcc.dg/tree-ssa/cond-bool-2.c: New test.
gcc/match.pd
gcc/testsuite/gcc.dg/tree-ssa/bit1neg-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/cond-bool-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/tree-ssa/cond-bool-2.c [new file with mode: 0644]