AArch64 GCC uses MOVI for low-64-bit integer SIMD constants.
GCC on AArch64 now generates more efficient code for certain 128-bit SIMD integer constants by using the `MOVI` instruction.
The AArch64 backend of GCC now optimizes the materialization of specific 128-bit integer SIMD constants. When the constant has a duplicated scalar value in its low 64 bits and zero in its high 64 bits, GCC will now emit the more efficient MOVI instruction. This improves code generation for Advanced SIMD (AdvSIMD) operations, eliminating the need for more complex instruction sequences.
In Details
The AArch64 backend's aarch64_simd_valid_imm function, responsible for determining immediate materialization strategies for AdvSIMD, gains an enhancement. Previously, 128-bit integer vector constants with only the lower 64 bits carrying a duplicated scalar value (and the upper 64 bits being zero) would not be recognized for MOVI (Move Immediate) instruction synthesis. This update extends aarch64_simd_valid_imm and aarch64_output_simd_imm to correctly identify such patterns and leverage the 64-bit MOVI instruction. This reduces instruction count and improves code density for a common…
For Context
Modern processors, especially those used in mobile devices and servers, have special instructions for performing the same operation on multiple pieces of data at once. This is called Single Instruction, Multiple Data, or SIMD. The AArch64 architecture (used in many ARM-based devices) has a set of these instructions called Advanced SIMD (AdvSIMD). When your program uses a constant value in these SIMD operations, the compiler needs to find an efficient way to load that constant into the processor's registers. This update to GCC, the compiler, improves how it handles specific 128-bit integer constants for AdvSIMD. If a 128-bit constant contains a repeated 64-bit value in its lower half and zeros in its upper half, GCC can now use a simpler, more direct instruction called MOVI (Move Immediate). This results in smaller and faster code compared to previous methods that might have required more complex sequences of instructions to achieve the same result.