GCC Newspaper
JULY 29, 2026
Date
/
Architectures
Components
Topics
News & Policy
loongarch

Fix conditional vector shuffle operand handling for LoongArch.

Corrected predicate logic for LoongArch's vector shuffle instructions to handle operand modes properly.

This commit addresses an issue in the LoongArch backend concerning the predicate par_const_vector_shf_set_operand, which was used to validate operands for constant vector shuffle instructions like lsx_vshuf4i. The predicate incorrectly accepted any mode for the selector operand because it was declared as VOIDmode. The fix modifies this predicate to be a special predicate and specifies VIMODE for the selector, ensuring it matches the expected mode and preventing incorrect folding of vector select operations.

In Details

The par_const_vector_shf_set_operand predicate in LoongArch's predicates.md was designed to check if a constant vector shuffle's selector operand matched the mode of the shuffled vector. However, due to the underlying lsx_vshuf4i_<lsxfmt_f> definitions using VOIDmode for the selector's mode field, the predicate would accept any mode. This commit refactors the predicate into a special predicate and ensures VIMODE is passed to it when processing lsx_vshuf4i, aligning the mode checking with the expected behavior and resolving issues arising from recent improvements in folding `vec_…

For Context
LoongArch
A family of RISC-based computer architectures developed in China.
VIMODE
Likely refers to a specific GCC internal mode representing a vector integer type, used for operations on vector data.
VOIDmode
A GCC internal mode representing an undefined or unused type, often used as a placeholder.
predicate
In GCC's machine description files (like .md), a predicate is a condition that must be true for a particular instruction pattern to match.
lsx_vshuf4i
A LoongArch specific instruction for performing a 4-element vector shuffle operation.
Filed Under: loongarchvectorbugfix