GCC Newspaper
NOVEMBER 30, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
internal-fn

Fix widening CLMUL for narrow _BitInt types

Corrected CLMUL widening logic for narrow _BitInt types to accurately compute the high half of the product.

This commit fixes a bug in the expand_CLMUL_WIDEN function where it incorrectly handled the high half of a widening carry-less multiplication (CLMUL) for narrow _BitInt types. Previously, it took a shortcut assuming the entire product fit within the operand’s mode, resulting in zero for the high half when bits above the type’s precision were involved. The fix ensures the high half is correctly computed by shifting the product right by the type’s precision when necessary.

In Details

The expand_CLMUL_WIDEN intrinsic expansion was not correctly calculating the high half of a widening CLMUL operation when the result's precision exceeded the operand type's precision, specifically for narrow _BitInt types. The shortcut if (mode_fits_bitwise_p(TARGET_MODE, CLMUL_RES_MODE)) was incorrectly applied, leading to hi being zeroed out. The fix correctly computes hi as (product >> bits_precision) when the product requires more bits than the operand type can hold, addressing PR128111.

For Context
_BitInt
A C++23 feature allowing arbitrary-precision integers. _BitInt(N) defines an integer type with exactly N bits.
CLMUL
Carry-Less Multiplication. A bitwise multiplication operation where carries are ignored. It's often used in cryptography and error correction codes.
intrinsic
A function that is implemented directly by the compiler, often mapping to a specific machine instruction. Intrinsic functions provide low-level access to hardware capabilities.
Filed Under: optimizationintegerbugfix