[all-commits] [llvm/llvm-project] 70a26a: [LoopVectorize] Add metadata to distinguish vector...

Adel Ejjeh via All-commits all-commits at lists.llvm.org
Wed Apr 29 09:03:51 PDT 2026


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 70a26a246446410297cd40b97ff707a28e147a49
      https://github.com/llvm/llvm-project/commit/70a26a246446410297cd40b97ff707a28e147a49
  Author: Adel Ejjeh <adel.ejjeh at amd.com>
  Date:   2026-04-29 (Wed, 29 Apr 2026)

  Changed paths:
    M llvm/docs/LangRef.rst
    M llvm/docs/TransformMetadata.rst
    M llvm/include/llvm/Transforms/Utils/LoopUtils.h
    M llvm/lib/Transforms/Scalar/WarnMissedTransforms.cpp
    M llvm/lib/Transforms/Utils/LoopUnroll.cpp
    M llvm/lib/Transforms/Utils/LoopUtils.cpp
    M llvm/lib/Transforms/Vectorize/VPlan.cpp
    A llvm/test/Transforms/LoopTransformWarning/vectorizer-loop-kind-unroll-warning.ll
    A llvm/test/Transforms/LoopUnroll/vectorizer-loop-kind-remarks.ll
    M llvm/test/Transforms/LoopVectorize/RISCV/remark-reductions.ll
    M llvm/test/Transforms/LoopVectorize/remarks-reduction-inloop.ll

  Log Message:
  -----------
  [LoopVectorize] Add metadata to distinguish vectorized loop body from scalar remainder (#190258)

Add two new loop metadata attributes — `llvm.loop.vectorize.body` and
`llvm.loop.vectorize.epilogue` — that the loop vectorizer sets on the
generated vector loop and epilogue loop respectively. The metadata is
only emitted when optimization remarks are enabled (`ORE->enabled()`),
so it has zero cost in normal compilation.

These enable downstream passes (LoopUnroll, WarnMissedTransforms) to
produce more precise optimization remarks. Instead of the generic "loop
not unrolled" warning on a source line that was vectorized, the unroller
can now report:
- **"vectorized loop"** for the main vector body
- **"epilogue loop"** for the scalar epilogue/remainder
- **"epilogue vectorized loop"** for an epilogue that was itself
vectorized during epilogue vectorization (carries both attributes)

A shared `getLoopVectorizeKindPrefix()` helper in
`LoopUtils.h`/`LoopUtils.cpp` reads the metadata and returns the
appropriate prefix string, used by both `LoopUnroll.cpp` and
`WarnMissedTransforms.cpp`. The metadata emission in `VPlan.cpp` uses
`Loop::addIntLoopAttribute` from the NFC PR #194676.

Two end-to-end tests exercise the full `loop-vectorize → loop-unroll`
pipeline with forced epilogue vectorization
(`-enable-epilogue-vectorization -epilogue-vectorization-force-VF=4`) to
produce all four loop categories from a single vectorizable function.
Each test also includes a plain (non-vectorized) function to cover the
baseline "loop" case. Both tests verify stderr diagnostic output and
YAML structured remarks.
**`LoopUnroll/vectorizer-loop-kind-remarks.ll`** checks for
successful-unroll remarks.
**`LoopTransformWarning/vectorizer-loop-kind-unroll-warning.ll`** checks
for failed-unroll warnings.

AI Disclaimer: this patch was generated with assistance of GitHub
Copilot/Claude Opus and reviewed by a human.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list