[1/2] PR88598: Optimise x * { 0 or 1, 0 or 1, ... }
authorRichard Sandiford <richard.sandiford@arm.com>
Mon, 7 Jan 2019 12:16:30 +0000 (12:16 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Mon, 7 Jan 2019 12:16:30 +0000 (12:16 +0000)
commit46c66a46aa33077bda821e0428cc7859945c04c8
tree4c12a6c6d89c857b70db55d83846f5b0a0828cf6
parent3340164d5db7a65cd98138f1eead1f2d66dd221c
[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.

From-SVN: r267645
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