Fix PR 105532: match.pd patterns calling tree_nonzero_bits with vector types
authorAndrew Pinski <apinski@marvell.com>
Wed, 2 Nov 2022 15:56:31 +0000 (15:56 +0000)
committerAndrew Pinski <apinski@marvell.com>
Wed, 21 Dec 2022 18:32:26 +0000 (18:32 +0000)
commit193fccaa5c3525e979a989835c47c76d2c49d10c
tree09f58b9f53e9287c91aa6a4eeb8a8ecf9a497b70
parent91e0d22025e0bf2af2e364cb7214a05512a0c431
Fix PR 105532: match.pd patterns calling tree_nonzero_bits with vector types

Even though this PR was reported with an ubsan issue, the problem is
tree_nonzero_bits is being called with an expression which is a vector type.
This fixes three patterns I noticed which does that.
And adds a testcase for one of the patterns.

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

gcc/ChangeLog:

PR tree-optimization/105532
* match.pd (~(X >> Y) -> ~X >> Y): Check if it is an integral
type before calling tree_nonzero_bits.
(popcount(X) + popcount(Y)): Likewise.
(popcount(X&C1)): Likewise.

gcc/testsuite/ChangeLog:

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