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

LoongArch: Fix ICE moving V1TI and V2TI constants

Fixes an internal compiler error (ICE) in LoongArch when moving V1TI and V2TI vector constants.

This commit resolves an ICE in the LoongArch backend when handling moves of V1TI and V2TI vector constants. The issue arose because the loongarch_output_move function incorrectly checked for CONST_INT instead of CONST_WIDE_INT for these vector types. By changing the check to CONST_SCALAR_INT_P, the compiler now correctly handles these constants, preventing the ICE and allowing new test cases for V1TI and V2TI constants to pass.

In Details

The loongarch_output_move function in the LoongArch backend's instruction output logic attempts to optimize moves of vector constants using vldi/xvldi. Previously, it checked if the vector elements were CONST_INT. However, V1TI and V2TI constants, which can contain CONST_WIDE_INT elements, were not handled. This commit adjusts the check to CONST_SCALAR_INT_P to correctly identify these wider integer constants, thereby avoiding a fall-through to gcc_unreachable and resolving the ICE. New test cases target these specific vector types.

For Context
V1TI
A LoongArch vector data type. 'V' denotes vector, '1' likely refers to a specific vector length or packing scheme, 'T' typically means 'signed', and 'I' means 'integer'.
V2TI
Similar to V1TI, a LoongArch vector data type. '2' might indicate a larger vector size or different packing compared to V1TI.
CONST_INT
GCC's internal representation for a constant integer value in the compiler's intermediate representation.
CONST_WIDE_INT
GCC's internal representation for a constant integer value that may require more than a standard machine word to represent.
ICE
Internal Compiler Error. A severe error detected by the compiler during its operation, indicating a bug in the compiler itself. The compilation process is aborted.
vldi/xvldi
LoongArch vector instructions for loading constants. 'vldi' is likely the base instruction, and 'xvldi' might be an extended version, possibly for larger constants or different addressing modes.
Filed Under: loongarchcompiler bugvector