Skip to content

Commit 81f1800

Browse files
author
GYT
committed
Emit better debug and opt-report messages when vectorization is disallowed in the LoopVectorizer
formatting formatting2 fix ;) vs. ); typos formatting3
1 parent 983c8b6 commit 81f1800

File tree

1 file changed

+31
-4
lines changed

1 file changed

+31
-4
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp

Lines changed: 31 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -182,14 +182,41 @@ void LoopVectorizeHints::setAlreadyVectorized() {
182182
bool LoopVectorizeHints::allowVectorization(
183183
Function *F, Loop *L, bool VectorizeOnlyWhenForced) const {
184184
if (getForce() == LoopVectorizeHints::FK_Disabled) {
185-
LLVM_DEBUG(dbgs() << "LV: Not vectorizing: #pragma vectorize disable.\n");
186-
emitRemarkWithHints();
185+
if (Force.Value == LoopVectorizeHints::FK_Disabled) {
186+
LLVM_DEBUG(dbgs() << "LV: Not vectorizing: #pragma vectorize disable.\n");
187+
ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedExplicitlyDisabled",
188+
TheLoop->getStartLoc(),
189+
TheLoop->getHeader())
190+
<< "loop not vectorized: vectorization is explicitly disabled");
191+
} else if (hasDisableAllTransformsHint(TheLoop)) {
192+
LLVM_DEBUG(
193+
dbgs() << "LV: Not vectorizing: loop hasDisableAllTransformsHint.\n");
194+
ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedTrafoDisabled",
195+
TheLoop->getStartLoc(),
196+
TheLoop->getHeader())
197+
<< "loop not vectorized: loop transformations are disabled");
198+
} else {
199+
// This should be unreachable unless there is a bug.
200+
LLVM_DEBUG(
201+
dbgs() << "LV: [FIXME] Not vectorizing: loop vect disabled for "
202+
"an unknown reason!\n");
203+
ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedUnknown",
204+
TheLoop->getStartLoc(),
205+
TheLoop->getHeader())
206+
<< "loop not vectorized: unknown reason, please file a bug "
207+
"report on the LLVM issue tracker");
208+
}
187209
return false;
188210
}
189211

190212
if (VectorizeOnlyWhenForced && getForce() != LoopVectorizeHints::FK_Enabled) {
191-
LLVM_DEBUG(dbgs() << "LV: Not vectorizing: No #pragma vectorize enable.\n");
192-
emitRemarkWithHints();
213+
LLVM_DEBUG(dbgs() << "LV: Not vectorizing: VectorizeOnlyWhenForced is set, "
214+
"and no #pragma vectorize enable.\n");
215+
ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedForceOnly",
216+
TheLoop->getStartLoc(),
217+
TheLoop->getHeader())
218+
<< "loop not vectorized: only vectorizing loops that "
219+
"explicitly request it");
193220
return false;
194221
}
195222

0 commit comments

Comments
 (0)