IT lexicon › Programming › Epilogue vectorization

Epilogue vectorization

Programming På svenska → Updated: 2026-11-07

Vectorizing the remainder loop as well, just with narrower vectors, so the leftovers don't have to be handled one element at a time.

With wide vectors and unrolling, the main loop may chew through 64 elements per iteration. That leaves a remainder of up to 63, and running it scalar can eat most of the gain on short trip counts. Epilogue vectorization adds a middle step: a second vector loop at, say, width eight, followed by a scalar loop for the last few stragglers.

GCC and LLVM both picked it up around 2019–2020. It's the alternative to tail folding on hardware where masked instructions are slow or missing, which still describes a lot of x86 code. The downside is size: one source loop can turn into three machine loops plus the runtime checks that choose between them.

← Back to the lexicon