AArch64: Cap suggested unroll factor for small known-niters loops
AArch64 vectorizer caps suggested unroll factor for small loops to avoid unnecessary overhead.
The AArch64 backend now caps the suggested unroll factor for small, known-iteration loops during vectorization. This prevents the backend from suggesting an excessively high unroll factor (e.g., 4 when only 1 or 2 are needed), which could lead to suboptimal code generation due to extra epilogue loops. The cap is calculated using CEIL(niters, VF) to ensure all scalar iterations are covered by the vectorized loop.
In Details
Modifies aarch64_vector_costs::determine_suggested_unroll_factor in config/aarch64/aarch64.cc to cap the suggested unroll factor for small known-niters loops. The cap is set to CEIL(niters, VF) to ensure full coverage without requiring an epilogue loop. This change addresses cases where the previous logic suggested an unroll factor larger than necessary for loops with few iterations, improving code generation quality for SVE vectorized loops.
- AArch64
- The 64-bit ARM architecture, a prevalent instruction set architecture for mobile and server processors.
- Vectorizer
- A compiler component that transforms scalar code into vector code, enabling parallel execution of operations on multiple data elements simultaneously.
- Unroll factor
- The number of times a loop's body is replicated during loop unrolling to reduce loop overhead and expose more instructions for parallel execution.
- SVE
- Scalable Vector Extension, an optional extension to the ARMv8-A architecture that provides variable-length vector processing.
- ILP
- Instruction-Level Parallelism, the degree to which instructions in a program can be executed in parallel.
- VF
- Vector Factor, representing the number of elements processed by a single vector instruction.