[AArch64] Use SVE MLA, MLS, MAD and MSB for conditional arithmetic
authorRichard Sandiford <richard.sandiford@arm.com>
Thu, 15 Aug 2019 08:22:07 +0000 (08:22 +0000)
committerRichard Sandiford <rsandifo@gcc.gnu.org>
Thu, 15 Aug 2019 08:22:07 +0000 (08:22 +0000)
commitb6c3aea1892c148c21f8b87668f344b2397f4aa5
treece3dcc012c010a984c7d56a052e556408229b0ba
parenta19ba9e1b15d248e5a13ee773f4acd4ae29fdeaa
[AArch64] Use SVE MLA, MLS, MAD and MSB for conditional arithmetic

This patch uses predicated MLA, MLS, MAD and MSB to implement
conditional "FMA"s on integers.  This also requires providing
the unpredicated optabs (fma and fnma) since otherwise
tree-ssa-math-opts.c won't try to use the conditional forms.

We still want to use shifts and adds in preference to multiplications,
so the patch makes the optab expanders check for that.

The tests cover floating-point types too, which are already handled,
and which were already tested to some extent by gcc.dg/vect.

2019-08-15  Richard Sandiford  <richard.sandiford@arm.com>
    Kugan Vivekanandarajah  <kugan.vivekanandarajah@linaro.org>

gcc/
* config/aarch64/aarch64-protos.h (aarch64_prepare_sve_int_fma)
(aarch64_prepare_sve_cond_int_fma): Declare.
* config/aarch64/aarch64.c (aarch64_convert_mult_to_shift)
(aarch64_prepare_sve_int_fma): New functions.
(aarch64_prepare_sve_cond_int_fma): Likewise.
* config/aarch64/aarch64-sve.md
(cond_<SVE_INT_BINARY:optab><SVE_I:mode>): Add a "@" marker.
(fma<SVE_I:mode>4, cond_fma<SVE_I:mode>, *cond_fma<SVE_I:mode>_2)
(*cond_fma<SVE_I:mode>_4, *cond_fma<SVE_I:mode>_any, fnma<SVE_I:mode>4)
(cond_fnma<SVE_I:mode>, *cond_fnma<SVE_I:mode>_2)
(*cond_fnma<SVE_I:mode>_4, *cond_fnma<SVE_I:mode>_any): New patterns.
(*madd<mode>): Rename to...
(*fma<mode>4): ...this.
(*msub<mode>): Rename to...
(*fnma<mode>4): ...this.

gcc/testsuite/
* gcc.target/aarch64/sve/cond_mla_1.c: New test.
* gcc.target/aarch64/sve/cond_mla_1_run.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_2.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_2_run.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_3.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_3_run.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_4.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_4_run.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_5.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_5_run.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_6.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_6_run.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_7.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_7_run.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_8.c: Likewise.
* gcc.target/aarch64/sve/cond_mla_8_run.c: Likewise.

Co-Authored-By: Kugan Vivekanandarajah <kuganv@linaro.org>
From-SVN: r274509
21 files changed:
gcc/ChangeLog
gcc/config/aarch64/aarch64-protos.h
gcc/config/aarch64/aarch64-sve.md
gcc/config/aarch64/aarch64.c
gcc/testsuite/ChangeLog
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_1_run.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_2_run.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_3_run.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_4_run.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_5.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_5_run.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_6.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_6_run.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_7.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_7_run.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/cond_mla_8_run.c [new file with mode: 0644]