Fix `~X & X` and `~X | X` patterns
commitff36932e4d6638e475d5c343c3032728f9925d3f
authorAndrew Pinski <apinski@marvell.com>
Wed, 2 Aug 2023 22:54:20 +0000 (2 15:54 -0700)
committerAndrew Pinski <apinski@marvell.com>
Thu, 3 Aug 2023 02:32:04 +0000 (2 19:32 -0700)
treeedecd8aae1d6d6fd5d8e88777ee3d07bf67004fd
parent1b53748c61a8b6489ca9a56a25037131335d3cc6
Fix `~X & X` and `~X | X` patterns

As Jakub noticed in https://gcc.gnu.org/pipermail/gcc-patches/2023-August/626039.html
what I did was not totally correct because sometimes chosing the wrong type.
So to get back to what the original code but keeping around the use of bitwise_inverted_equal_p,
we just need to check if the types of the two catupures are the same type.

Also adds a testcase for the problem Jakub found.

Committed as obvious after a bootstrap and test.

gcc/ChangeLog:

* match.pd (`~X & X`): Check that the types match.
(`~x | x`, `~x ^ x`): Likewise.

gcc/testsuite/ChangeLog:

* gcc.c-torture/execute/20230802-1.c: New test.
gcc/match.pd
gcc/testsuite/gcc.c-torture/execute/20230802-1.c [new file with mode: 0644]