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

bitintlower: Fix _BitInt rotates with signed operands

Correctly lowers large/huge _BitInt rotates involving signed operands, fixing incorrect casts and missing uses.

This commit fixes an issue in the lowering of large and huge _BitInt rotates when a signed operand is involved. Previously, the code incorrectly cast signed operands to themselves instead of their unsigned variants and failed to use the cast result. This resolves a bug where these operations were not handled correctly, ensuring proper code generation for bit-integer rotates.

In Details

The gimple-lower-bitint pass incorrectly handled LROTATE_EXPR and RROTATE_EXPR involving signed large/huge _BitInt operands. When the right-hand side operand was not a constant, the pass mistakenly cast the signed operand to the same signed type instead of its unsigned counterpart, and the result of this cast was unused. This patch corrects the cast target to the unsigned type and ensures the cast result is properly utilized in the lowered GIMPLE code.

For Context
_BitInt
A GCC extension for arbitrary-precision integers, allowing users to specify integers of any bit width.
gimple-lower-bitint
A GCC compiler pass that lowers operations on _BitInt types into GIMPLE, GCC's intermediate representation.
LROTATE_EXPR / RROTATE_EXPR
Intermediate Representation (IR) expressions representing left and right bitwise rotations, respectively.
GIMPLE
GCC's Internal Multiple Expression processing, a three-address intermediate representation used within the compiler.
INTEGER_CST
An intermediate representation node representing a constant integer value.
Filed Under: bitintloweringrotate