-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[LV] Emit better debug and opt-report messages when vectorization is disallowed in the LoopVectorizer #158513
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from 2 commits
81f1800
6d941ff
c0e6aec
c290bec
109b3fd
3c4c8de
fa19ccc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -182,14 +182,41 @@ 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: [FIXME] Not vectorizing: loop vect disabled for " | ||
"an unknown reason!\n"); | ||
ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedUnknown", | ||
TheLoop->getStartLoc(), | ||
TheLoop->getHeader()) | ||
<< "loop not vectorized: unknown reason, please file a bug " | ||
"report on the LLVM issue tracker"); | ||
Comment on lines
+199
to
+207
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. for unreachable cases, we ususally either assert that they cannot happen or use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Here, given that the stakes seem to be low (incorrect remark/debug msg) I felt it's more appropriate to handle it with a FIXME message. But I could add an |
||
} | ||
return false; | ||
} | ||
|
||
if (VectorizeOnlyWhenForced && getForce() != LoopVectorizeHints::FK_Enabled) { | ||
LLVM_DEBUG(dbgs() << "LV: Not vectorizing: No #pragma vectorize enable.\n"); | ||
emitRemarkWithHints(); | ||
LLVM_DEBUG(dbgs() << "LV: Not vectorizing: VectorizeOnlyWhenForced is set, " | ||
"and no #pragma vectorize enable.\n"); | ||
ORE.emit(OptimizationRemarkMissed(LV_NAME, "MissedForceOnly", | ||
TheLoop->getStartLoc(), | ||
TheLoop->getHeader()) | ||
<< "loop not vectorized: only vectorizing loops that " | ||
"explicitly request it"); | ||
return false; | ||
} | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this duplicated from emitRemarkWithHints?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am planning to refactor and rename emitRemarkWithHints in a future PR. Its name does not reflect well what it is doing and it does not let the caller emit a remark more specific than "loop not vectorized". So for now, I have inlined the relevant part of emitRemarkWithHints here.