Add RISC-V splitter for narrowing loads in load-shift-store sequences.
New RISC-V instruction pattern simplifies load-shift-store sequences, reducing dynamic instructions.
GCC introduces a new splitter for RISC-V to optimize sequences involving a wide load, a shift, and a narrow store. This pattern is reduced to a simple narrow load and narrow store, effectively eliminating the shift operation and saving dynamic instructions. The change is critical for performance and has been tested on multiple RISC-V targets.
In Details
GCC's RISC-V backend gains a new instruction pattern in gcc/config/riscv/riscv.md to recognize and simplify load->shift->store sequences. This specific pattern, involving a wide load followed by a shift and then a narrow store, is transformed into a more efficient narrow load and narrow store. This optimization is crucial for performance, especially on architectures where such sequences are common. The splitter handles mode conversions and address adjustments automatically.
- RISC-V
- An open-standard instruction set architecture based on open RISC principles, designed for simplicity and modularity.
- splitter
- In compiler optimization, a 'splitter' is a pattern or rule that breaks down a complex instruction or sequence into simpler, more efficient ones. This is a key part of the instruction selection and optimization process.
- SI mode
- A machine mode in GCC representing a single integer, typically 32 bits.
- HI mode
- A machine mode in GCC representing a half-integer, typically 16 bits.
- RTL
- Register Transfer Language, an intermediate representation used by GCC to represent code before it is translated into machine code.