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

aarch64: Ensure unsigned arguments for .CLZ and .POPCOUNT intrinsics

Corrects type conversions for signed arguments to AArch64's `.CLZ` and `.POPCOUNT` intrinsics.

This commit ensures that signed vector arguments passed to AArch64’s vclz and vcnt intrinsics are correctly converted to their unsigned equivalents before being folded into .CLZ and .POPCOUNT internal functions. This resolves a type mismatch issue where signed arguments were incorrectly used with intrinsics defined only for unsigned types. The generated code remains the same, but the internal representation is now type-safe.

In Details

The NEON built-in intrinsics vclz_s8 (and variants) and vcnt_s8 (and variants) on AArch64 fold to the internal functions .CLZ and .POPCOUNT, respectively. The issue was that for signed vector types, the argument passed to these IFNs was signed. Since .CLZ and .POPCOUNT expect unsigned arguments, this commit introduces a VIEW_CONVERT_EXPR to cast the signed vector argument to its unsigned counterpart before the fold. This ensures type correctness for the internal function calls, while the resulting machine code is unaffected.

For Context
AArch64
The 64-bit ARM architecture, a popular instruction set architecture for mobile and server processors.
intrinsic
A function or operation provided directly by the compiler that maps to a specific, often highly optimized, machine instruction.
vclz
A NEON intrinsic function that performs a 'count leading zeros' operation on vector elements.
vcnt
A NEON intrinsic function that performs a 'population count' (count of set bits) operation on vector elements.
.CLZ
An internal function representation for 'count leading zeros'.
.POPCOUNT
An internal function representation for 'population count' (counting set bits).
Filed Under: aarch64intrinsicstype safetycompiler