GCC Newspaper
JUNE 15, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
gcc/aarch64 Performance Win

AArch64: Implement FIRSTP and LASTP SVE instructions

The Arm Scalable Vector Extension (SVE) now supports FIRSTP and LASTP instructions in streaming mode under SME2.2, with new intrinsics and constant folding opt…

The Arm Scalable Vector Extension (SVE) now supports FIRSTP and LASTP instructions in streaming mode under SME2.2. These instructions determine the scalar index of the first or last true predicate element. New intrinsics have been added, along with constant folding optimizations. The patterns for these new instructions are implemented using UNSPECs as they can’t be expressed in terms of standard RTL.

In Details

SVE2.2 and SME2.2 add FIRSTP/LASTP instructions that compute the index of the first/last active element in a vector. This commit implements the intrinsics in aarch64-sve-builtins-sve2.cc and defines new instruction patterns in aarch64-sve2.md, using UNSPECs because the instructions can't be expressed in standard RTL. The implementation includes constant folding except for LASTP under -msve-vector-bits=scalable.

For Context

The Scalable Vector Extension (SVE) is an Arm architecture extension that allows vector instructions to operate on vectors of varying lengths. This allows code to be written once and then run on different hardware with different vector lengths. Streaming SVE (SME) is an extension to SVE that allows vector operations to operate on streams of data. FIRSTP and LASTP are instructions that find the index of the first or last predicated element in a vector. This commit adds support for these new instructions in SVE2.2 and SME2.2.

Filed Under: aarch64svesmeintrinsicsoptimization