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

LoongArch: Fix sign-extension mode in heterogeneous widen operations

Corrects the RTL generation for sign-extended operands in LoongArch's heterogeneous widening operations.

This commit fixes an issue in LoongArch’s SIMD (Single Instruction, Multiple Data) instructions where heterogeneous widening operations were incorrectly handling sign-extended operands. The generated RTL used the wrong vector mode for these operands, leading to potential assertions in CSE or issues in later optimization passes. The fix ensures the correct vector mode is used, aligning with the expected output for widening operations.

In Details

LoongArch's SIMD implementation in GCC had a bug in its heterogeneous widening instruction templates (simd_<optab>w_evod_<mode>_hetero). Specifically, when combining a zero-extended operand with a sign-extended operand to produce a <WVEC_HALF> result, the sign-extended operand was incorrectly generating RTL with <WVEC> mode instead of <WVEC_HALF>. This commit corrects the mode to <WVEC_HALF> for the sign-extended operand, resolving issues that could manifest during CSE or combine passes.

Filed Under: loongarchsimdvectorizationcompiler-rtl