RISC-V adds small loop unrolling support
New -munroll-only-small-loops option provides conservative loop unrolling for RISC-V, balancing performance gains with code size.
A new option, -munroll-only-small-loops, has been introduced for the RISC-V backend to enable conservative loop unrolling. This feature selectively unrolls small loops based on instruction thresholds to improve performance without significantly increasing code size or cache misses. It is enabled by default at -O2 and above, mirroring behavior on i386, and can be overridden by explicit unrolling flags. Existing tests not focused on unrolling are adjusted to maintain their original behavior.
In Details
RISC-V backend gains controlled loop unrolling via -munroll-only-small-loops. This option targets small loops based on per-tune instruction limits and unroll factors, mitigating the code-size/cache downsides of aggressive unrolling. It integrates with existing -funroll-loops behavior and uses new tune parameters like small_loop_unroll_ninsns. It mirrors i386's default enablement at -O2+.
- loop unrolling
- A compiler optimization that duplicates the body of a loop to reduce loop overhead and potentially expose more instruction-level parallelism, at the cost of increased code size.
- RISC-V
- An open-source instruction set architecture (ISA) that is modular and extensible, gaining popularity for embedded systems and high-performance computing.
- -O2
- A GCC optimization level that enables a suite of optimizations aimed at good performance without excessive compile times.
- -mtune
- A GCC flag that optimizes code for a specific processor's microarchitecture without changing the instruction set used.