[llvm] [LV] Emit better debug and opt-report messages when vectorization is disallowed in the LoopVectorizer (PR #158513)
Florian Hahn via llvm-commits
llvm-commits at lists.llvm.org
Sun Oct 26 20:03:42 PDT 2025
================
@@ -182,14 +182,40 @@ void LoopVectorizeHints::setAlreadyVectorized() {
bool LoopVectorizeHints::allowVectorization(
Function *F, Loop *L, bool VectorizeOnlyWhenForced) const {
if (getForce() == LoopVectorizeHints::FK_Disabled) {
- LLVM_DEBUG(dbgs() << "LV: Not vectorizing: #pragma vectorize disable.\n");
- emitRemarkWithHints();
+ if (Force.Value == LoopVectorizeHints::FK_Disabled) {
+ LLVM_DEBUG(dbgs() << "LV: Not vectorizing: #pragma vectorize disable.\n");
+ ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedExplicitlyDisabled",
+ TheLoop->getStartLoc(),
+ TheLoop->getHeader())
+ << "loop not vectorized: vectorization is explicitly disabled");
+ } else if (hasDisableAllTransformsHint(TheLoop)) {
+ LLVM_DEBUG(
+ dbgs() << "LV: Not vectorizing: loop hasDisableAllTransformsHint.\n");
+ ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedTransformsDisabled",
+ TheLoop->getStartLoc(),
+ TheLoop->getHeader())
+ << "loop not vectorized: loop transformations are disabled");
+ } else {
+ // This should be unreachable unless there is a bug.
+ LLVM_DEBUG(dbgs() << "LV: [BUG] Not vectorizing: loop vect disabled for "
----------------
fhahn wrote:
In LLVM, it is common to use `llvm_unreachable`, if not, better to drop `[BUG]`
https://github.com/llvm/llvm-project/pull/158513
More information about the llvm-commits
mailing list