mirror of
https://github.com/capstone-engine/llvm-capstone.git
synced 2024-10-10 12:55:00 +00:00
[LV] Port the remarks in processLoop to the new streaming API
This completes LV. llvm-svn: 282821
This commit is contained in:
parent
4fd9c42279
commit
951c6b1955
@ -6979,8 +6979,8 @@ bool LoopVectorizePass::processLoop(Loop *L) {
|
||||
// Looking at the diagnostic output is the only way to determine if a loop
|
||||
// was vectorized (other than looking at the IR or machine code), so it
|
||||
// is important to generate an optimization remark for each loop. Most of
|
||||
// these messages are generated by emitOptimizationRemarkAnalysis. Remarks
|
||||
// generated by emitOptimizationRemark and emitOptimizationRemarkMissed are
|
||||
// these messages are generated as OptimizationRemarkAnalysis. Remarks
|
||||
// generated as OptimizationRemark and OptimizationRemarkMissed are
|
||||
// less verbose reporting vectorized loops and unvectorized loops that may
|
||||
// benefit from vectorization, respectively.
|
||||
|
||||
@ -7080,7 +7080,7 @@ bool LoopVectorizePass::processLoop(Loop *L) {
|
||||
unsigned UserIC = Hints.getInterleave();
|
||||
|
||||
// Identify the diagnostic messages that should be produced.
|
||||
std::string VecDiagMsg, IntDiagMsg;
|
||||
std::pair<StringRef, std::string> VecDiagMsg, IntDiagMsg;
|
||||
bool VectorizeLoop = true, InterleaveLoop = true;
|
||||
if (Requirements.doesNotMeet(F, L, Hints)) {
|
||||
DEBUG(dbgs() << "LV: Not vectorizing: loop did not meet vectorization "
|
||||
@ -7091,26 +7091,32 @@ bool LoopVectorizePass::processLoop(Loop *L) {
|
||||
|
||||
if (VF.Width == 1) {
|
||||
DEBUG(dbgs() << "LV: Vectorization is possible but not beneficial.\n");
|
||||
VecDiagMsg =
|
||||
"the cost-model indicates that vectorization is not beneficial";
|
||||
VecDiagMsg = std::make_pair(
|
||||
"VectorizationNotBeneficial",
|
||||
"the cost-model indicates that vectorization is not beneficial");
|
||||
VectorizeLoop = false;
|
||||
}
|
||||
|
||||
if (IC == 1 && UserIC <= 1) {
|
||||
// Tell the user interleaving is not beneficial.
|
||||
DEBUG(dbgs() << "LV: Interleaving is not beneficial.\n");
|
||||
IntDiagMsg =
|
||||
"the cost-model indicates that interleaving is not beneficial";
|
||||
IntDiagMsg = std::make_pair(
|
||||
"InterleavingNotBeneficial",
|
||||
"the cost-model indicates that interleaving is not beneficial");
|
||||
InterleaveLoop = false;
|
||||
if (UserIC == 1)
|
||||
IntDiagMsg +=
|
||||
if (UserIC == 1) {
|
||||
IntDiagMsg.first = "InterleavingNotBeneficialAndDisabled";
|
||||
IntDiagMsg.second +=
|
||||
" and is explicitly disabled or interleave count is set to 1";
|
||||
}
|
||||
} else if (IC > 1 && UserIC == 1) {
|
||||
// Tell the user interleaving is beneficial, but it explicitly disabled.
|
||||
DEBUG(dbgs()
|
||||
<< "LV: Interleaving is beneficial but is explicitly disabled.");
|
||||
IntDiagMsg = "the cost-model indicates that interleaving is beneficial "
|
||||
"but is explicitly disabled or interleave count is set to 1";
|
||||
IntDiagMsg = std::make_pair(
|
||||
"InterleavingBeneficialButDisabled",
|
||||
"the cost-model indicates that interleaving is beneficial "
|
||||
"but is explicitly disabled or interleave count is set to 1");
|
||||
InterleaveLoop = false;
|
||||
}
|
||||
|
||||
@ -7121,22 +7127,31 @@ bool LoopVectorizePass::processLoop(Loop *L) {
|
||||
const char *VAPassName = Hints.vectorizeAnalysisPassName();
|
||||
if (!VectorizeLoop && !InterleaveLoop) {
|
||||
// Do not vectorize or interleaving the loop.
|
||||
ORE->emitOptimizationRemarkAnalysis(VAPassName, L, VecDiagMsg);
|
||||
ORE->emitOptimizationRemarkAnalysis(LV_NAME, L, IntDiagMsg);
|
||||
ORE->emit(OptimizationRemarkAnalysis(VAPassName, VecDiagMsg.first,
|
||||
L->getStartLoc(), L->getHeader())
|
||||
<< VecDiagMsg.second);
|
||||
ORE->emit(OptimizationRemarkAnalysis(LV_NAME, IntDiagMsg.first,
|
||||
L->getStartLoc(), L->getHeader())
|
||||
<< IntDiagMsg.second);
|
||||
return false;
|
||||
} else if (!VectorizeLoop && InterleaveLoop) {
|
||||
DEBUG(dbgs() << "LV: Interleave Count is " << IC << '\n');
|
||||
ORE->emitOptimizationRemarkAnalysis(VAPassName, L, VecDiagMsg);
|
||||
ORE->emit(OptimizationRemarkAnalysis(VAPassName, VecDiagMsg.first,
|
||||
L->getStartLoc(), L->getHeader())
|
||||
<< VecDiagMsg.second);
|
||||
} else if (VectorizeLoop && !InterleaveLoop) {
|
||||
DEBUG(dbgs() << "LV: Found a vectorizable loop (" << VF.Width << ") in "
|
||||
<< DebugLocStr << '\n');
|
||||
ORE->emitOptimizationRemarkAnalysis(LV_NAME, L, IntDiagMsg);
|
||||
ORE->emit(OptimizationRemarkAnalysis(LV_NAME, IntDiagMsg.first,
|
||||
L->getStartLoc(), L->getHeader())
|
||||
<< IntDiagMsg.second);
|
||||
} else if (VectorizeLoop && InterleaveLoop) {
|
||||
DEBUG(dbgs() << "LV: Found a vectorizable loop (" << VF.Width << ") in "
|
||||
<< DebugLocStr << '\n');
|
||||
DEBUG(dbgs() << "LV: Interleave Count is " << IC << '\n');
|
||||
}
|
||||
|
||||
using namespace ore;
|
||||
if (!VectorizeLoop) {
|
||||
assert(IC > 1 && "interleave count should not be 1 or 0");
|
||||
// If we decided that it is not legal to vectorize the loop, then
|
||||
@ -7144,9 +7159,10 @@ bool LoopVectorizePass::processLoop(Loop *L) {
|
||||
InnerLoopUnroller Unroller(L, PSE, LI, DT, TLI, TTI, AC, ORE, IC);
|
||||
Unroller.vectorize(&LVL, CM.MinBWs);
|
||||
|
||||
ORE->emitOptimizationRemark(LV_NAME, L,
|
||||
Twine("interleaved loop (interleaved count: ") +
|
||||
Twine(IC) + ")");
|
||||
ORE->emit(OptimizationRemark(LV_NAME, "Interleaved", L->getStartLoc(),
|
||||
L->getHeader())
|
||||
<< "interleaved loop (interleaved count: "
|
||||
<< NV("InterleaveCount", IC) << ")");
|
||||
} else {
|
||||
// If we decided that it is *legal* to vectorize the loop, then do it.
|
||||
InnerLoopVectorizer LB(L, PSE, LI, DT, TLI, TTI, AC, ORE, VF.Width, IC);
|
||||
@ -7160,10 +7176,11 @@ bool LoopVectorizePass::processLoop(Loop *L) {
|
||||
AddRuntimeUnrollDisableMetaData(L);
|
||||
|
||||
// Report the vectorization decision.
|
||||
ORE->emitOptimizationRemark(
|
||||
LV_NAME, L, Twine("vectorized loop (vectorization width: ") +
|
||||
Twine(VF.Width) + ", interleaved count: " + Twine(IC) +
|
||||
")");
|
||||
ORE->emit(OptimizationRemark(LV_NAME, "Vectorized", L->getStartLoc(),
|
||||
L->getHeader())
|
||||
<< "vectorized loop (vectorization width: "
|
||||
<< NV("VectorizationFactor", VF.Width)
|
||||
<< ", interleaved count: " << NV("InterleaveCount", IC) << ")");
|
||||
}
|
||||
|
||||
// Mark the loop as already vectorized to avoid vectorizing again.
|
||||
|
Loading…
Reference in New Issue
Block a user