]> git.ipfire.org Git - thirdparty/gcc.git/commit
[1/2] PR88598: Optimise x * { 0 or 1, 0 or 1, ... }
authorrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Jan 2019 12:16:30 +0000 (12:16 +0000)
committerrsandifo <rsandifo@138bc75d-0d04-0410-961f-82ee72b054a4>
Mon, 7 Jan 2019 12:16:30 +0000 (12:16 +0000)
commit34dc851a2016ea1fc7e71c2ad0ccb9af713a2954
tree4c12a6c6d89c857b70db55d83846f5b0a0828cf6
parent7809a7efc6d1dec97cba7064c13c785ca5cd929f
[1/2] PR88598: Optimise x * { 0 or 1, 0 or 1, ... }

The PR has:

    vect__6.24_42 = vect__5.23_41 * { 0.0, 1.0e+0, 0.0, 0.0 };

which for -fno-signed-zeros -fno-signaling-nans can be simplified to:

    vect__6.24_42 = vect__5.23_41 & { 0, -1, 0, 0 };

I deliberately didn't handle COMPLEX_CST or CONSTRUCTOR in
initializer_each_zero_or_onep since there are no current use cases.

The patch also makes (un)signed_type_for handle floating-point types.
I tried to audit all callers and the few that handle null returns would
be unaffected.

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

gcc/
PR tree-optimization/88598
* tree.h (initializer_each_zero_or_onep): Declare.
* tree.c (initializer_each_zero_or_onep): New function.
(signed_or_unsigned_type_for): Handle float types too.
(unsigned_type_for, signed_type_for): Update comments accordingly.
* match.pd: Fold x * { 0 or 1, 0 or 1, ...} to
x & { 0 or -1, 0 or -1, ... }.

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

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