]> git.ipfire.org Git - people/ms/gcc.git/commit
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>
Sat, 11 Mar 2023 01:29:15 +0000 (01:29 +0000)
commit67608f7a2cf3eff99654ab3f44d5183049e3b36c
tree726613386937b9cfaf01cebfb33d5e844422c490
parent7ba91ff96b7d1d2f93792054a94176603d50093f
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.

Committed after a 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.

(cherry picked from commit 193fccaa5c3525e979a989835c47c76d2c49d10c)
gcc/match.pd
gcc/testsuite/gcc.c-torture/compile/vector-shift-1.c [new file with mode: 0644]