]> git.ipfire.org Git - thirdparty/gcc.git/commit
[2/2] PR88598: Optimise reduc (bit_and)
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Jan 2019 12:17:10 +0000 (12:17 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Jan 2019 12:17:10 +0000 (12:17 +0000)
commitdf2148cfe86b20c02f11fac377021a410f491780
tree4b1605d010ed5331fcd70d90790c5ce41dd2f7c2
parent34dc851a2016ea1fc7e71c2ad0ccb9af713a2954
[2/2] PR88598: Optimise reduc (bit_and)

This patch folds certain reductions of X & CST to X[I] & CST[I] if I is
the only nonzero element of CST.  This includes the motivating case in
which CST[I] is -1.

We could do the same for REDUC_MAX on unsigned types, but I wasn't sure
that that special case was worth it.

2019-01-07  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
PR tree-optimization/88598
* tree.h (single_nonzero_element): Declare.
* tree.c (single_nonzero_element): New function.
* match.pd: Fold certain reductions of X & CST to X[I] & CST[I]
if I is the only nonzero element of CST.

gcc/testsuite/
PR tree-optimization/88598
* gcc.dg/vect/pr88598-1.c: New test.
* gcc.dg/vect/pr88598-2.c: Likewise.
* gcc.dg/vect/pr88598-3.c: Likewise.
* gcc.dg/vect/pr88598-4.c: Likewise.
* gcc.dg/vect/pr88598-5.c: Likewise.
* gcc.dg/vect/pr88598-6.c: Likewise.

git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@267646 138bc75d-0d04-0410-961f-82ee72b054a4
gcc/ChangeLog
gcc/match.pd
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/pr88598-1.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/pr88598-2.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/pr88598-3.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/pr88598-4.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/pr88598-5.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/pr88598-6.c [new file with mode: 0644]
gcc/tree.c
gcc/tree.h