Skip to content
Open
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 31 additions & 4 deletions llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Copy link
Contributor

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?

Copy link
Contributor Author

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.

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
Copy link
Contributor

Choose a reason for hiding this comment

The 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 llvm_unreacahble

Copy link
Contributor Author

Choose a reason for hiding this comment

The 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 llvm_unreacahble if you wish.

}
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;
}

Expand Down
Loading