[15/n] PR85694: Try to split existing casts in widened patterns
authorRichard Sandiford <richard.sandiford@arm.com>
Tue, 3 Jul 2018 10:03:17 +0000 (10:03 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Tue, 3 Jul 2018 10:03:17 +0000 (10:03 +0000)
commit4ef79c960aa0967cf0298dc496a30a40d86ebd3c
tree0ae63c6c6dc83b6cd7647a38c2a0757969ef2439
parent370c2ebe8fa20e0812cd2d533d4ed38ee2d37c85
[15/n] PR85694: Try to split existing casts in widened patterns

The main over-widening patch can introduce quite a few extra casts,
and in many cases those casts simply "tap into" an intermediate
point in an existing extension.  E.g. if we have:

    unsigned char a;
    int ax = (int) a;

and a later operation using ax is shortened to "unsigned short",
we would need:

    unsigned short ax' = (unsigned short) a;

The a->ax extension requires one set of unpacks to get to unsigned
short and another set of unpacks to get to int.  The first set are
then duplicated for ax'.  If both ax and ax' are needed, the a->ax'
extension would end up counting twice during cost calculations.

This patch rewrites the original:

    int ax = (int) a;

into a pattern:

    unsigned short ax' = (unsigned short) a;
    int ax = (int) ax';

so that each extension only counts once.

2018-07-03  Richard Sandiford  <richard.sandiford@arm.com>

gcc/
* tree-vect-patterns.c (vect_split_statement): New function.
(vect_convert_input): Use it to try to split an existing cast.

gcc/testsuite/
* gcc.dg/vect/vect-over-widen-5.c: Test that the extensions
get split into two for use by the over-widening pattern.
* gcc.dg/vect/vect-over-widen-6.c: Likewise.
* gcc.dg/vect/vect-over-widen-7.c: Likewise.
* gcc.dg/vect/vect-over-widen-8.c: Likewise.
* gcc.dg/vect/vect-over-widen-9.c: Likewise.
* gcc.dg/vect/vect-over-widen-10.c: Likewise.
* gcc.dg/vect/vect-over-widen-11.c: Likewise.
* gcc.dg/vect/vect-over-widen-12.c: Likewise.
* gcc.dg/vect/vect-over-widen-13.c: Likewise.
* gcc.dg/vect/vect-over-widen-14.c: Likewise.
* gcc.dg/vect/vect-over-widen-15.c: Likewise.
* gcc.dg/vect/vect-over-widen-16.c: Likewise.
* gcc.dg/vect/vect-over-widen-22.c: New test.

From-SVN: r262334
16 files changed:
gcc/ChangeLog
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.dg/vect/vect-over-widen-10.c
gcc/testsuite/gcc.dg/vect/vect-over-widen-11.c
gcc/testsuite/gcc.dg/vect/vect-over-widen-12.c
gcc/testsuite/gcc.dg/vect/vect-over-widen-13.c
gcc/testsuite/gcc.dg/vect/vect-over-widen-14.c
gcc/testsuite/gcc.dg/vect/vect-over-widen-15.c
gcc/testsuite/gcc.dg/vect/vect-over-widen-16.c
gcc/testsuite/gcc.dg/vect/vect-over-widen-22.c [new file with mode: 0644]
gcc/testsuite/gcc.dg/vect/vect-over-widen-5.c
gcc/testsuite/gcc.dg/vect/vect-over-widen-6.c
gcc/testsuite/gcc.dg/vect/vect-over-widen-7.c
gcc/testsuite/gcc.dg/vect/vect-over-widen-8.c
gcc/testsuite/gcc.dg/vect/vect-over-widen-9.c
gcc/tree-vect-patterns.c