Abstract
The RISC-V Vector Extension (RVV) has emerged as a promising vector architecture for high-performance computing. It enables parallel computing capability for RISC-V CPUs by introducing additional vector instructions and vector registers. To fully utilize the potential of RVV, it is crucial to optimize the auto-vectorization capabilities of compilers. Auto-vectorization is a widely used method for parallelizing scalar programs on vector machines. It examines the input program to identify the parallelizable section and then maps it to the underlying vector architecture. This paper focuses on enhancing LLVM's auto-vectorization for linear recurrence programs on RVV, with a specific emphasis on a well-studied computation pattern called scan (all-prefix-sums). Linear recurrence programs are prevalent in diverse computational domains, and their efficient execution is vital for achieving optimal performance. However, the auto-vectorization on current LLVM's vectorizer is hindered by the loop-carried data dependence of recurrence programs. In this work, we propose novel techniques to address the challenges of auto-vectorizing linear recurrence programs on RVV, leveraging the unique features of RVV and extending LLVM's vectorization capabilities. The experiment shows that our auto-vectorized plus-scan can achieved 17.64x speedup on RVV compared to LLVM 16.0.0.