Richard Sandiford 3268942a8b aarch64: Fix SVE vec_perm for VL2048 VNx16QI
SVE's vec_perm pattern is restricted to constant VLs.  There are two
expansions: one for when the selector is known to refer to only the
first vector, and one for the general case.

The first expansion uses a single TBL whereas the fallback uses a
five-instruction sequence that includes a SUB of nunits and two TBLs.

Normally the first expansion is purely an optimisation.  However,
in the specific case of a VL2048 permutation of bytes, the first
form is needed for correctness, since the SUB of nunits (256)
would be truncated to a SUB of zero.

For example, in:

  svint8_t f(svint8_t x, svint8_t y, svint8_t z) {
    return __builtin_shuffle(x, y, z);
  }

"z" can only select from "x" for VL2048.  The testcase previously
generated:

        tbl     z0.b, {z0.b}, z2.b
        tbl     z1.b, {z1.b}, z2.b
        orr     z0.d, z0.d, z1.d
        ret

where the SUB is optimised away.  This sequence is equivalent to:

    return __builtin_shuffle(x | y, x | y, z);

even though "y" should be entirely ignored.

I used "<= nunits - 1U" rather than "< nunits" to match the existing
check and as a hopefully natural way of making the rhs unsigned.

gcc/
	* config/aarch64/aarch64.cc (aarch64_expand_sve_vec_perm): Check
	whether all indices of a variable selector refer to the first
	values vector.

gcc/testsuite/
	* gcc.target/aarch64/sve/vec_perm_2.c: New test.
	* gcc.target/aarch64/sve/vec_perm_3.c: Likewise.
2026-05-04 21:06:53 +01:00
2026-05-01 00:16:27 +00:00
2026-04-29 00:16:40 +00:00
2026-04-30 00:16:31 +00:00
2026-05-03 00:16:23 +00:00
2026-05-02 00:16:28 +00:00

This directory contains the GNU Compiler Collection (GCC).

The GNU Compiler Collection is free software.  See the files whose
names start with COPYING for copying permission.  The manuals, and
some of the runtime libraries, are under different terms; see the
individual source files for details.

The directory INSTALL contains copies of the installation information
as HTML and plain text.  The source of this information is
gcc/doc/install.texi.  The installation information includes details
of what is included in the GCC sources and what files GCC installs.

See the file gcc/doc/gcc.texi (together with other files that it
includes) for usage and porting information.  An online readable
version of the manual is in the files gcc/doc/gcc.info*.

See http://gcc.gnu.org/bugs/ for how to report bugs usefully.

Copyright years on GCC source files may be listed using range
notation, e.g., 1987-2012, indicating that every year in the range,
inclusive, is a copyrightable year that could otherwise be listed
individually.
Description
No description provided
Readme 4.2 GiB
Languages
C++ 30.7%
C 30.2%
Ada 14.4%
D 6.1%
Go 5.7%
Other 12.4%