GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
arm Performance Win

Add Neon expander for `negv2di2` on ARM.

Introduces a Neon expander for `negv2di2` to avoid unnecessary scalarization on ARM.

This commit adds a Neon expander for the negv2di2 operation on ARM architectures. While ARM’s Neon instruction set has a VSUB.i64 instruction that can perform negation, it lacks a dedicated VNEG instruction for this mode. This forces scalarization, which can be inefficient. The new expander utilizes VSUB.i64 to perform the negation directly using Neon, improving performance.

In Details

This patch adds a new instruction expansion pattern for negv2di2 (negation of a 2-element double-integer vector) targeting ARM's NEON SIMD extension. The NEON instruction set includes VSUB.i64 which can emulate negation, but lacks a direct VNEG.i64. Without this expander, the compiler would scalarize negv2di2 to scalar operations, leading to suboptimal code generation. The new pattern in config/arm/neon.md uses VSUB.i64 to implement this efficiently on the vector level. New test cases are added in gcc.target/arm/.

For Context
NEON
ARM's advanced SIMD (Single Instruction, Multiple Data) extension. It provides hardware acceleration for multimedia and signal processing tasks by performing operations on multiple data points simultaneously.
expander
A compiler component that replaces a high-level or abstract operation with a sequence of lower-level or more concrete instructions.
negv2di2
Represents the negation of a 2-element vector of 64-bit integers.
VSUB.i64
A NEON instruction for subtracting 64-bit integers.
scalarize
To convert an operation that works on vectors (multiple data elements) into a sequence of operations that work on individual elements (scalars). This is often done when a vector instruction is unavailable or inefficient.
SIMD
Single Instruction, Multiple Data. A class of parallel computers in Flynn's taxonomy. SIMD instructions perform the same operation on multiple data points simultaneously.
Filed Under: armneonvectorizationoptimization