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

LoongArch vector pick instructions optimized for register overlap.

LoongArch vector pick instructions are optimized by leveraging register overlap to reduce vector width.

This commit optimizes LoongArch’s vector pick instructions (vpickve2gr) by exploiting the overlap between vector and floating-point registers. It reduces the effective vector width used by these instructions, replacing them with simpler scalar operations when possible. This optimization targets specific variants like xvpickve2gr.w and xvpickve2gr.d to improve code generation efficiency on LoongArch architectures.

In Details

On LoongArch, the lower parts of larger vector registers overlap with smaller vector or floating-point registers. This commit modifies the lasx.md and lsx.md files to leverage this overlap for vpickve2gr instructions. For example, [x]vpickve2gr.w operations that select 32-bit elements from the lower 64 bits of a vector register are replaced by movfr2gr.s or movfrh2gr.s. Similarly, [x]vpickve2gr.d selecting 64-bit elements from the lower 128 bits are replaced by movfr2gr.d. Other variants are optimized using specific vpickve2gr forms or by reusing existing instructions that m…

For Context
LoongArch
A 64-bit RISC instruction set architecture developed in China, featuring extensions for vector processing (LSX, LASX) and other capabilities.
vector register
A CPU register designed to hold multiple data elements (e.g., integers, floating-point numbers) that can be operated on simultaneously in a single instruction (SIMD - Single Instruction, Multiple Data).
vpickve2gr.w
A LoongArch vector instruction that picks two 32-bit elements from a vector register and places them into general-purpose registers. The '.w' likely indicates word-sized (32-bit) elements.
vpickve2gr.d
A LoongArch vector instruction that picks two 64-bit elements from a vector register and places them into general-purpose registers. The '.d' likely indicates doubleword-sized (64-bit) elements.
movfr2gr.s
A LoongArch instruction that moves a single-precision (32-bit) floating-point value from a floating-point register to a general-purpose register.
movfr2gr.d
A LoongArch instruction that moves a double-precision (64-bit) floating-point value from a floating-point register to a general-purpose register.
LSX
Loongson SIMD Extension. A vector processing extension for LoongArch architecture.
LASX
Loongson Advanced SIMD Extension. An advanced vector processing extension for LoongArch architecture, often wider than LSX.
Filed Under: loongarchvectorizationoptimization