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

Perform VABA accumulation in unsigned type for AArch64 intrinsics

Ensures VABA accumulation uses unsigned types to avoid overflow issues.

This commit modifies the folding of AArch64 vaba_ intrinsics to perform the accumulation in an unsigned type. Previously, for signed element types, the accumulation used signed types, leading to undefined overflow behavior and subsequent incorrect folding. By accumulating in unsigned types and then converting back, the compiler correctly models the intrinsic’s wrapping behavior, preventing miscompilations and ensuring correct results, particularly in operations like vshr_n_s8 after vaba_s8.

In Details

This fix targets PR target/128556 concerning the folding of AArch64 vaba_ (vector absolute difference and accumulate) intrinsics. These intrinsics are typically folded into an ABD operation followed by a PLUS_EXPR. When used with signed element types, the PLUS_EXPR operates on signed types. If this addition overflows, it results in Undefined Behavior (UB), even though the hardware intrinsic wraps around. Subsequent folding passes might then assume no overflow occurred. This commit modifies the gimple_abs_diff::fold method to perform the accumulation using unsigned types (`VIEW_CONVERT…

For Context
VABA
Vector Absolute Difference and Accumulate. An ARM NEON instruction that calculates the absolute difference between two vectors and adds the result to an accumulator vector.
Intrinsic
A special function provided by the compiler that maps directly to a specific machine instruction or a small sequence of instructions, often for performance-critical operations.
GIMPLE
GCC's internal representation (IR) used after the front-end has parsed the source code. It's a three-address-like code that simplifies many optimization passes.
Undefined Behavior (UB)
Behavior that results from an implementation or program error that is not defined by the C, C++, or other language standards. Compilers are free to assume UB does not occur and can optimize code based on this assumption, potentially leading to incorrect results if UB is actually present.
SIMD
Single Instruction, Multiple Data. A class of parallel computers in Flynn's taxonomy that perform the same operation on multiple data points simultaneously.
Filed Under: aarch64gccsimdintrinsicsoptimization