forked from OSchip/llvm-project
Improved printing of analysis diagnostics in the loop vectorizer.
This patch ensures that every analysis diagnostic produced by the vectorizer will be printed if the loop has a vectorization hint on it. The condition has also been improved to prevent printing when a disabling hint is specified. llvm-svn: 246132
This commit is contained in:
parent
6e25aeea96
commit
e0f400feaa
|
@ -862,14 +862,16 @@ public:
|
|||
bool allowVectorization(Function *F, Loop *L, bool AlwaysVectorize) const {
|
||||
if (getForce() == LoopVectorizeHints::FK_Disabled) {
|
||||
DEBUG(dbgs() << "LV: Not vectorizing: #pragma vectorize disable.\n");
|
||||
emitOptimizationRemarkAnalysis(F->getContext(), DEBUG_TYPE, *F,
|
||||
emitOptimizationRemarkAnalysis(F->getContext(),
|
||||
vectorizeAnalysisPassName(), *F,
|
||||
L->getStartLoc(), emitRemark());
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!AlwaysVectorize && getForce() != LoopVectorizeHints::FK_Enabled) {
|
||||
DEBUG(dbgs() << "LV: Not vectorizing: No #pragma vectorize enable.\n");
|
||||
emitOptimizationRemarkAnalysis(F->getContext(), DEBUG_TYPE, *F,
|
||||
emitOptimizationRemarkAnalysis(F->getContext(),
|
||||
vectorizeAnalysisPassName(), *F,
|
||||
L->getStartLoc(), emitRemark());
|
||||
return false;
|
||||
}
|
||||
|
@ -882,7 +884,7 @@ public:
|
|||
// vectorize.disable to be used without disabling the pass and errors
|
||||
// to differentiate between disabled vectorization and a width of 1.
|
||||
emitOptimizationRemarkAnalysis(
|
||||
F->getContext(), DEBUG_TYPE, *F, L->getStartLoc(),
|
||||
F->getContext(), vectorizeAnalysisPassName(), *F, L->getStartLoc(),
|
||||
"loop not vectorized: vectorization and interleaving are explicitly "
|
||||
"disabled, or vectorize width and interleave count are both set to "
|
||||
"1");
|
||||
|
@ -915,9 +917,16 @@ public:
|
|||
unsigned getWidth() const { return Width.Value; }
|
||||
unsigned getInterleave() const { return Interleave.Value; }
|
||||
enum ForceKind getForce() const { return (ForceKind)Force.Value; }
|
||||
bool isForced() const {
|
||||
return getForce() == LoopVectorizeHints::FK_Enabled || getWidth() > 1 ||
|
||||
getInterleave() > 1;
|
||||
const char *vectorizeAnalysisPassName() const {
|
||||
// If hints are provided that don't disable vectorization use the
|
||||
// AlwaysPrint pass name to force the frontend to print the diagnostic.
|
||||
if (getWidth() == 1)
|
||||
return LV_NAME;
|
||||
if (getForce() == LoopVectorizeHints::FK_Disabled)
|
||||
return LV_NAME;
|
||||
if (getForce() == LoopVectorizeHints::FK_Undefined && getWidth() == 0)
|
||||
return LV_NAME;
|
||||
return DiagnosticInfo::AlwaysPrint;
|
||||
}
|
||||
|
||||
private:
|
||||
|
@ -1039,15 +1048,14 @@ private:
|
|||
static void emitAnalysisDiag(const Function *TheFunction, const Loop *TheLoop,
|
||||
const LoopVectorizeHints &Hints,
|
||||
const LoopAccessReport &Message) {
|
||||
// If a loop hint is provided the diagnostic is always produced.
|
||||
const char *Name = Hints.isForced() ? DiagnosticInfo::AlwaysPrint : LV_NAME;
|
||||
const char *Name = Hints.vectorizeAnalysisPassName();
|
||||
LoopAccessReport::emitAnalysis(Message, TheFunction, TheLoop, Name);
|
||||
}
|
||||
|
||||
static void emitMissedWarning(Function *F, Loop *L,
|
||||
const LoopVectorizeHints &LH) {
|
||||
emitOptimizationRemarkMissed(F->getContext(), DEBUG_TYPE, *F,
|
||||
L->getStartLoc(), LH.emitRemark());
|
||||
emitOptimizationRemarkMissed(F->getContext(), LV_NAME, *F, L->getStartLoc(),
|
||||
LH.emitRemark());
|
||||
|
||||
if (LH.getForce() == LoopVectorizeHints::FK_Enabled) {
|
||||
if (LH.getWidth() != 1)
|
||||
|
@ -1497,8 +1505,7 @@ public:
|
|||
void addRuntimePointerChecks(unsigned Num) { NumRuntimePointerChecks = Num; }
|
||||
|
||||
bool doesNotMeet(Function *F, Loop *L, const LoopVectorizeHints &Hints) {
|
||||
// If a loop hint is provided the diagnostic is always produced.
|
||||
const char *Name = Hints.isForced() ? DiagnosticInfo::AlwaysPrint : LV_NAME;
|
||||
const char *Name = Hints.vectorizeAnalysisPassName();
|
||||
bool Failed = false;
|
||||
if (UnsafeAlgebraInst &&
|
||||
Hints.getForce() == LoopVectorizeHints::FK_Undefined &&
|
||||
|
@ -1799,21 +1806,22 @@ struct LoopVectorize : public FunctionPass {
|
|||
IC = UserIC > 0 ? UserIC : IC;
|
||||
|
||||
// Emit diagnostic messages, if any.
|
||||
const char *VAPassName = Hints.vectorizeAnalysisPassName();
|
||||
if (!VectorizeLoop && !InterleaveLoop) {
|
||||
// Do not vectorize or interleaving the loop.
|
||||
emitOptimizationRemarkAnalysis(F->getContext(), DEBUG_TYPE, *F,
|
||||
emitOptimizationRemarkAnalysis(F->getContext(), VAPassName, *F,
|
||||
L->getStartLoc(), VecDiagMsg);
|
||||
emitOptimizationRemarkAnalysis(F->getContext(), DEBUG_TYPE, *F,
|
||||
emitOptimizationRemarkAnalysis(F->getContext(), LV_NAME, *F,
|
||||
L->getStartLoc(), IntDiagMsg);
|
||||
return false;
|
||||
} else if (!VectorizeLoop && InterleaveLoop) {
|
||||
DEBUG(dbgs() << "LV: Interleave Count is " << IC << '\n');
|
||||
emitOptimizationRemarkAnalysis(F->getContext(), DEBUG_TYPE, *F,
|
||||
emitOptimizationRemarkAnalysis(F->getContext(), VAPassName, *F,
|
||||
L->getStartLoc(), VecDiagMsg);
|
||||
} else if (VectorizeLoop && !InterleaveLoop) {
|
||||
DEBUG(dbgs() << "LV: Found a vectorizable loop (" << VF.Width << ") in "
|
||||
<< DebugLocStr << '\n');
|
||||
emitOptimizationRemarkAnalysis(F->getContext(), DEBUG_TYPE, *F,
|
||||
emitOptimizationRemarkAnalysis(F->getContext(), LV_NAME, *F,
|
||||
L->getStartLoc(), IntDiagMsg);
|
||||
} else if (VectorizeLoop && InterleaveLoop) {
|
||||
DEBUG(dbgs() << "LV: Found a vectorizable loop (" << VF.Width << ") in "
|
||||
|
@ -1828,7 +1836,7 @@ struct LoopVectorize : public FunctionPass {
|
|||
InnerLoopUnroller Unroller(L, SE, LI, DT, TLI, TTI, IC);
|
||||
Unroller.vectorize(&LVL);
|
||||
|
||||
emitOptimizationRemark(F->getContext(), DEBUG_TYPE, *F, L->getStartLoc(),
|
||||
emitOptimizationRemark(F->getContext(), LV_NAME, *F, L->getStartLoc(),
|
||||
Twine("interleaved loop (interleaved count: ") +
|
||||
Twine(IC) + ")");
|
||||
} else {
|
||||
|
@ -1844,7 +1852,7 @@ struct LoopVectorize : public FunctionPass {
|
|||
AddRuntimeUnrollDisableMetaData(L);
|
||||
|
||||
// Report the vectorization decision.
|
||||
emitOptimizationRemark(F->getContext(), DEBUG_TYPE, *F, L->getStartLoc(),
|
||||
emitOptimizationRemark(F->getContext(), LV_NAME, *F, L->getStartLoc(),
|
||||
Twine("vectorized loop (vectorization width: ") +
|
||||
Twine(VF.Width) + ", interleaved count: " +
|
||||
Twine(IC) + ")");
|
||||
|
|
|
@ -1,9 +1,17 @@
|
|||
; RUN: opt < %s -loop-vectorize -force-vector-width=4 -S -pass-remarks-missed='loop-vectorize' 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -loop-vectorize -force-vector-width=4 -S 2>&1 | FileCheck %s
|
||||
; RUN: opt < %s -loop-vectorize -force-vector-width=1 -S 2>&1 | FileCheck %s -check-prefix=NOANALYSIS
|
||||
; RUN: opt < %s -loop-vectorize -force-vector-width=4 -pass-remarks-missed='loop-vectorize' -S 2>&1 | FileCheck %s -check-prefix=MOREINFO
|
||||
|
||||
; CHECK: remark: source.cpp:4:5: loop not vectorized: loop contains a switch statement
|
||||
; CHECK: remark: source.cpp:4:5: loop not vectorized: use -Rpass-analysis=loop-vectorize for more info (Force=true, Vector Width=4)
|
||||
; CHECK: warning: source.cpp:4:5: loop not vectorized: failed explicitly specified loop vectorization
|
||||
|
||||
; NOANALYSIS-NOT: remark: {{.*}}
|
||||
; NOANALYSIS: warning: source.cpp:4:5: loop not interleaved: failed explicitly specified loop interleaving
|
||||
|
||||
; MOREINFO: remark: source.cpp:4:5: loop not vectorized: loop contains a switch statement
|
||||
; MOREINFO: remark: source.cpp:4:5: loop not vectorized: use -Rpass-analysis=loop-vectorize for more info (Force=true, Vector Width=4)
|
||||
; MOREINFO: warning: source.cpp:4:5: loop not vectorized: failed explicitly specified loop vectorization
|
||||
|
||||
; CHECK: _Z11test_switchPii
|
||||
; CHECK-NOT: x i32>
|
||||
; CHECK: ret
|
||||
|
|
Loading…
Reference in New Issue