arXiv:2611.03917cs.PLNov 2026

Manuscript Offprint

arXiv:2611.03917

Silent Degradation during Auto-Vectorization of bf16/fp16 on RISC-V Under LLVM

Vaishnavi Kouru, Robert Chun

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Vaishnavi Kouru

Department of Computer Science

San Jose State University

San Jose, CA, USA

vkouru07@gmail.com

Robert Chun

Department of Computer Science

San Jose State University

San Jose, CA, USA

robert.chun@sjsu.edu

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.

I. INTRODUCTION

Using lower-precision numeric types, such as 8-bit integers and 16-bit floating-point formats (e.g., bfloat16 and IEEE half-precision fp16), in place of 32-bit floating point is a growing trend as developers try to reduce memory bandwidth and increase throughput in AI inference workloads [1], [2]. Model weights are commonly distributed in bf16 or fp16, and a developer who keeps them in that format would reasonably expect the inner loops that use them to run at least as fast as their fp32 versions, since they move half as many bytes. Among these narrow types, integer and floating-point formats are not vectorized equally well by default: as shown below, an 8-bit integer type vectorizes as cleanly as standard 32-bit floating point, while 16-bit floating-point types do not, unless additional target-feature flags are enabled.

RISC-V has also become a common choice for AI edge inference, partly because of its openly specified Vector extension (RVV) [3], which lets compilers auto-vectorize loops without hand-written SIMD intrinsics. Inference runtimes such as llama.cpp now include RVV kernels [4], and recent work on RISC-V LLM inference reports that the choice of compiler, and its support for ISA extensions, changes throughput [5].

Developers targeting RISC-V with a mainstream compiler may want to know whether auto-vectorization works equally well across the low-precision types AI workloads depend on, or whether some types are handled worse than others without any clear sign in the console output.

This paper examines that question with LLVM's auto-vectorizer, by compiling versions of a common multiply-accumulate loop (an operation of the form dst+=a∗bdst + = a * b, computed in one step) for the same RVV target, changing only the numeric type.

The compiler does not treat these types the same way: integer narrowing vectorizes cleanly by default, while both floating-point narrow types degrade to scalar-heavy fallback code unless additional target-feature flags (zvfbfmin/zvfbfwma for bf16, zvfhmin for fp16) are enabled, and the two floating-point types degrade in different, increasingly severe ways. The degradation is silent in a practical sense: the build succeeds, the output is numerically correct, and no warning is printed unless optimization remarks are requested. The compiler's remarks, while accurate, do not distinguish between a degradation that a compiler flag fixes and one that reflects an inherent cost of the operation, so nothing in the text points toward the fix.

The extensions and their effects are documented, actively developed LLVM and RISC-V features [6], [7], [8]. This study describes, at the assembly and diagnostic level, how vectorization quality degrades across three AI-relevant narrow types under the same method, measures the resulting difference in executed instructions under emulation, traces the degradation to the stage of the LLVM pipeline where it is decided, and identifies a specific gap in how compiler remarks report that degradation to developers.