aarch64: Support permutes on unpacked SVE vectors
authorRichard Sandiford <richard.sandiford@arm.com>
Fri, 6 Nov 2020 16:49:28 +0000 (16:49 +0000)
committerRichard Sandiford <richard.sandiford@arm.com>
Fri, 6 Nov 2020 16:49:28 +0000 (16:49 +0000)
commit6c3ce63b04b38f84c0357e4648383f0e3ab11cd9
treefef5cc0a801d7a562146c02b4a97f79daa4cb14c
parent9b11203e33f999933aaa99bba779ffd7cd329849
aarch64: Support permutes on unpacked SVE vectors

This patch adds support for permuting unpacked SVE vectors using:

- DUP
- EXT
- REV[BHW]
- REV
- TRN[12]
- UZP[12]
- ZIP[12]

This involves rewriting the REV[BHW] permute code so that the inputs
and outputs of the insn pattern have the same mode as the vectors
being permuted.  This is different from the ACLE form, where the
reversal happens within individual elements rather than within
groups of multiple elements.

The patch does not add a conditional version of REV[BHW].  I'll come
back to that once we have partial-vector comparisons and selects.

The patch is really just enablement, adding an extra tool to the
toolbox.  It doesn't bring any significant vectorisation opportunities
on its own.  However, the patch does have one artificial example that
is now vectorised in a better way than before.

gcc/
* config/aarch64/aarch64-modes.def (VNx2BF, VNx4BF): Adjust nunits
and alignment based on the current VG.
* config/aarch64/iterators.md (SVE_ALL, SVE_24, SVE_2, SVE_4): Add
partial SVE BF modes.
(UNSPEC_REVBHW): New unspec.
(Vetype, Vesize, Vctype, VEL, Vel, vwcore, V_INT_CONTAINER)
(v_int_container, VPRED, vpred): Handle partial SVE BF modes.
(container_bits, Vcwtype): New mode attributes.
* config/aarch64/aarch64-sve.md
(@aarch64_sve_revbhw_<SVE_ALL:mode><PRED_HSD:mode>): New pattern.
(@aarch64_sve_dup_lane<mode>): Extended from SVE_FULL to SVE_ALL.
(@aarch64_sve_rev<mode>, @aarch64_sve_<perm_insn><mode>): Likewise.
(@aarch64_sve_ext<mode>): Likewise.
* config/aarch64/aarch64.c (aarch64_classify_vector_mode): Handle
E_VNx2BFmode and E_VNx4BFmode.
(aarch64_evpc_rev_local): Base the analysis on the container size
instead of the element size.  Use the new aarch64_sve_revbhw
patterns for SVE.
(aarch64_evpc_dup): Handle partial SVE data modes.  Use the
container size instead of the element size when applying the
SVE immediate limit.  Fix a previously incorrect bounds check.
(aarch64_expand_vec_perm_const_1): Handle partial SVE data modes.

gcc/testsuite/
* gcc.target/aarch64/sve/dup_lane_2.c: New test.
* gcc.target/aarch64/sve/dup_lane_3.c: Likewise.
* gcc.target/aarch64/sve/ext_4.c: Likewise.
* gcc.target/aarch64/sve/rev_2.c: Likewise.
* gcc.target/aarch64/sve/revhw_1.c: Likewise.
* gcc.target/aarch64/sve/revhw_2.c: Likewise.
* gcc.target/aarch64/sve/slp_perm_8.c: Likewise.
* gcc.target/aarch64/sve/trn1_2.c: Likewise.
* gcc.target/aarch64/sve/trn2_2.c: Likewise.
* gcc.target/aarch64/sve/uzp1_2.c: Likewise.
* gcc.target/aarch64/sve/uzp2_2.c: Likewise.
* gcc.target/aarch64/sve/zip1_2.c: Likewise.
* gcc.target/aarch64/sve/zip2_2.c: Likewise.
17 files changed:
gcc/config/aarch64/aarch64-modes.def
gcc/config/aarch64/aarch64-sve.md
gcc/config/aarch64/aarch64.c
gcc/config/aarch64/iterators.md
gcc/testsuite/gcc.target/aarch64/sve/dup_lane_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/dup_lane_3.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/ext_4.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/rev_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/revhw_1.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/revhw_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/slp_perm_8.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/trn1_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/trn2_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/uzp1_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/uzp2_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/zip1_2.c [new file with mode: 0644]
gcc/testsuite/gcc.target/aarch64/sve/zip2_2.c [new file with mode: 0644]