GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
aarch64

AArch64 rejects masked left rotates in right-rotate patterns

AArch64 rejects masked left rotates in right-rotate patterns to prevent incorrect code generation.

The AArch64 backend now rejects masked left rotations when they are used in patterns that emit ROR (rotate right) instructions without negating the count. This prevents incorrect expansion of masked negative-count splitters that could allocate new pseudoregisters after reload. A new selftest verifies this behavior.

In Details

This commit refines the AArch64 backend's instruction selection for rotate operations. It specifically targets patterns in aarch64.md that handle masked register counts, particularly ror (rotate right). Left rotations (rol) are now excluded from patterns like aarch64_<optab>_reg_<mode>3_mask1 and aarch64_<optab>_reg_<mode>3_neg_mask2 when they are intended to be converted to ror with specific masking or negation. This is crucial because the expansion of masked negative counts for left rotates can lead to issues with register allocation post-reload.

For Context
ROR
Rotate Right: A bitwise operation that shifts bits to the right, with bits shifted off one end re-entering on the other end.
AArch64
The 64-bit ARM architecture, commonly used in mobile devices and servers.
RTL
Register Transfer Language: An intermediate representation used by GCC to describe operations on registers and memory.
Pseudos
Pseudoregisters: Temporary registers used by the compiler during optimization and code generation that do not directly correspond to physical machine registers.
Reload
A compiler pass that assigns physical registers to pseudoregisters, spilling values to memory if necessary.
Filed Under: aarch64code-generation