Silent Degradation during Auto-Vectorization of bf16/fp16 on RISC-V Under LLVM
Vaishnavi Kouru, Robert Chun
Abstract
Low-precision numeric types such as 8-bit integers, bfloat16, and half-precision floating point (fp16) are often used in AI inference workloads to reduce memory bandwidth, and RISC-V's openly specified Vector extension (RVV) is a natural target for compiling such workloads with auto-vectorization. This paper examines whether LLVM's RISC-V auto-vectorizer handles these narrow types equally well, using a multiply-accumulate loop written for fp32, int8, bf16, and fp16. Under a common baseline target (-march=rv64gcv), int8 and fp32 vectorize cleanly, while bf16 and fp16 degrade to increasingly scalar-heavy fallback code, with fp16 falling back to per-element software conversion calls, unless additional target-feature extensions (zvfbfmin/zvfbfwma, zvfhmin) are enabled. Under QEMU user-mode emulation, the baseline bf16 and fp16 kernels execute 17.0× and 75.9× as many dynamic instructions as their extension-enabled counterparts. Compiler diagnostics do report this degradation, but do not distinguish, in their wording, between a limitation that a compiler flag resolves entirely and one reflecting an inherent conversion cost, leaving no direct signal toward the fix. These results are supported by assembly-level instruction analysis, by direct inspection of LLVM's optimization remarks, and by dynamic instruction counts collected under emulation.
Create a lesson
Related papers
Handling JAX
Oghenevwogaga Ebresafe, Daniel Zheng, Gordon Plotkin et al.
Functional Logic Programming: Improving Logic Programs with Ease
Michael Hanus
Vectorizing Recurrences over Semirings
Yihong Zhang, Bala Vinaithirthan, Karima Ma et al.
MBUndo: Sound, Automatic, and Efficient Measurement-Based Uncomputation for Quantum Circuits
Shengyuan Yang, Charles Yuan
te-comp: A Complete MLIR Compiler Generating Self-Contained C Inference Engines for MCUs
Van Chan Ngo
Stochastic Summaries: Characterizing Structured Datasets Using Probabilistic Programs
Jack Stanek, Adithya Murali