RISC-V recognizes POSTINDEX_ST macro-fusion
RISC-V target can now fuse scalar stores followed by an in-place base register update, improving code density and performance.
GCC adds recognition for POSTINDEX_ST macro-fusion on RISC-V, combining a scalar integer or floating-point store with a subsequent in-place update of its base register. This optimization reuses existing helpers for indexed memory access. The fusion is disabled by default and its associated tests are XFAILed, awaiting explicit CPU enablement.
In Details
This commit adds RISCV_FUSE_POSTINDEX_ST to the RISC-V fusion table in riscv-fusion.cc. It identifies patterns where a scalar store is immediately followed by an ADDI-type in-place update of the store's base register. It reuses the riscv_fuse_indexed_mem_helper and store-source constraints. The fusion is disabled by default and its tests are XFAILed.
- macro-fusion
- A compiler optimization technique where multiple independent machine instructions are combined into a single, more complex instruction. This can improve performance by reducing instruction fetch, decode, and execution overhead.
- RISC-V
- An open-standard Instruction Set Architecture (ISA) based on Reduced Instruction Set Computer principles. GCC supports various RISC-V profiles and extensions.
- POSTINDEX_ST
- A pattern where a store operation is followed by an update to its base address register.
- scalar store
- A store instruction that writes a single value (e.g., an integer or floating-point number) to memory.
- ADDI-type update
- An instruction that adds an immediate value to a register, used here to update a base address after a memory access.
- XFAIL
- A test directive in GCC's testsuite indicating that a test is expected to fail for a specific reason (e.g., a feature is not yet fully supported or enabled). This allows the test to be included without causing the overall test suite to fail.