Add x86 addsub SLP pattern
authorRichard Biener <rguenther@suse.de>
Mon, 31 May 2021 11:19:01 +0000 (13:19 +0200)
committerRichard Biener <rguenther@suse.de>
Thu, 24 Jun 2021 11:08:25 +0000 (13:08 +0200)
commit7a6c31f0f84a7295433ebac09b94fae2d5cc2892
treeae70aac1f6e8305d23a8ee08ce92d3b57d4a3100
parent9872bd8c35be0f4d475fac739115cf5b82cdabc0
Add x86 addsub SLP pattern

This addds SLP pattern recognition for the SSE3/AVX [v]addsubp{ds} v0, v1
instructions which compute { v0[0] - v1[0], v0[1], + v1[1], ... }
thus subtract, add alternating on lanes, starting with subtract.

It adds a corresponding optab and direct internal function,
vec_addsub$a3 and renames the existing i386 backend patterns to
the new canonical name.

The SLP pattern matches the exact alternating lane sequence rather
than trying to be clever and anticipating incoming permutes - we
could permute the two input vectors to the needed lane alternation,
do the addsub and then permute the result vector back but that's
only profitable in case the two input or the output permute will
vanish - something Tamars refactoring of SLP pattern recog should
make possible.

2021-06-17  Richard Biener  <rguenther@suse.de>

* config/i386/sse.md (avx_addsubv4df3): Rename to
vec_addsubv4df3.
(avx_addsubv8sf3): Rename to vec_addsubv8sf3.
(sse3_addsubv2df3): Rename to vec_addsubv2df3.
(sse3_addsubv4sf3): Rename to vec_addsubv4sf3.
* config/i386/i386-builtin.def: Adjust.
* internal-fn.def (VEC_ADDSUB): New internal optab fn.
* optabs.def (vec_addsub_optab): New optab.
* tree-vect-slp-patterns.c (class addsub_pattern): New.
(slp_patterns): Add addsub_pattern.
* tree-vect-slp.c (vect_optimize_slp): Disable propagation
across CFN_VEC_ADDSUB.
* tree-vectorizer.h (vect_pattern::vect_pattern): Make
m_ops optional.
* doc/md.texi (vec_addsub<mode>3): Document.

* gcc.target/i386/vect-addsubv2df.c: New testcase.
* gcc.target/i386/vect-addsubv4sf.c: Likewise.
* gcc.target/i386/vect-addsubv4df.c: Likewise.
* gcc.target/i386/vect-addsubv8sf.c: Likewise.
* gcc.target/i386/vect-addsub-2.c: Likewise.
* gcc.target/i386/vect-addsub-3.c: Likewise.
14 files changed:
gcc/config/i386/i386-builtin.def
gcc/config/i386/sse.md
gcc/doc/md.texi
gcc/internal-fn.def
gcc/optabs.def
gcc/testsuite/gcc.target/i386/vect-addsub-2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/vect-addsub-3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/vect-addsubv2df.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/vect-addsubv4df.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/vect-addsubv4sf.c [new file with mode: 0644]
gcc/testsuite/gcc.target/i386/vect-addsubv8sf.c [new file with mode: 0644]
gcc/tree-vect-slp-patterns.c
gcc/tree-vect-slp.c
gcc/tree-vectorizer.h