GCC Newspaper
OCTOBER 6, 2026
Date
/
Architectures
Components
Topics
News & Policy
Other
loongarch

LoongArch: Fix __builtin_bitreverse16 ICE on LA32R

Fixes an internal compiler error for __builtin_bitreverse16 on LoongArch 32-bit Reduced.

This commit resolves an internal compiler error (ICE) on the LoongArch 32-bit Reduced (LA32R) architecture when using the __builtin_bitreverse16 intrinsic. The fix involves disabling this intrinsic specifically for the LA32R target, along with a new test case to confirm the correction.

In Details

This change disables the bitreverseqi2 RTL pattern on the LoongArch LA32R architecture to fix an ICE. The bitreverseqi2 pattern, when used for 16-bit bit reversal, appears to be incompatible or has an issue on the LA32R variant, likely due to specific instruction encoding or available vector operations. The fix ensures correct compilation for this target by preventing the problematic pattern from being selected.

For Context
LoongArch
A family of RISC-based instruction set architectures developed in China, with variants for 32-bit and 64-bit systems.
LA32R
LoongArch 32-bit Reduced architecture, a specific configuration of the LoongArch ISA.
ICE
Internal Compiler Error. An unexpected condition encountered during compilation that causes the compiler to terminate abnormally.
__builtin_bitreverse16
A GCC intrinsic function that reverses the order of bits in a 16-bit integer.
RTL
Register Transfer Language. An intermediate representation used by GCC to represent the program before generating machine code. Optimization passes operate on RTL.
Filed Under: loongarchcompiler errorintrinsic