-
Notifications
You must be signed in to change notification settings - Fork 14.3k
LV/Legality: fix style after cursory reading (NFC) #100363
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
Conversation
@llvm/pr-subscribers-llvm-transforms Author: Ramkumar Ramachandra (artagnon) ChangesFull diff: https://github.com/llvm/llvm-project/pull/100363.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
index cafec165f6d6f..9474ac374147f 100644
--- a/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
+++ b/llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp
@@ -47,7 +47,7 @@ cl::opt<bool>
HintsAllowReordering("hints-allow-reordering", cl::init(true), cl::Hidden,
cl::desc("Allow enabling loop hints to reorder "
"FP operations during vectorization."));
-}
+} // namespace llvm
// TODO: Move size-based thresholds out of legality checking, make cost based
// decisions instead of hard thresholds.
@@ -216,20 +216,18 @@ void LoopVectorizeHints::emitRemarkWithHints() const {
TheLoop->getStartLoc(),
TheLoop->getHeader())
<< "loop not vectorized: vectorization is explicitly disabled";
- else {
- OptimizationRemarkMissed R(LV_NAME, "MissedDetails",
- TheLoop->getStartLoc(), TheLoop->getHeader());
- R << "loop not vectorized";
- if (Force.Value == LoopVectorizeHints::FK_Enabled) {
- R << " (Force=" << NV("Force", true);
- if (Width.Value != 0)
- R << ", Vector Width=" << NV("VectorWidth", getWidth());
- if (getInterleave() != 0)
- R << ", Interleave Count=" << NV("InterleaveCount", getInterleave());
- R << ")";
- }
- return R;
+ OptimizationRemarkMissed R(LV_NAME, "MissedDetails", TheLoop->getStartLoc(),
+ TheLoop->getHeader());
+ R << "loop not vectorized";
+ if (Force.Value == LoopVectorizeHints::FK_Enabled) {
+ R << " (Force=" << NV("Force", true);
+ if (Width.Value != 0)
+ R << ", Vector Width=" << NV("VectorWidth", getWidth());
+ if (getInterleave() != 0)
+ R << ", Interleave Count=" << NV("InterleaveCount", getInterleave());
+ R << ")";
}
+ return R;
});
}
@@ -271,8 +269,8 @@ void LoopVectorizeHints::getHintsFromMetadata() {
if (!MD || MD->getNumOperands() == 0)
continue;
S = dyn_cast<MDString>(MD->getOperand(0));
- for (unsigned i = 1, ie = MD->getNumOperands(); i < ie; ++i)
- Args.push_back(MD->getOperand(i));
+ for (unsigned Idx = 1; Idx < MD->getNumOperands(); ++Idx)
+ Args.push_back(MD->getOperand(Idx));
} else {
S = dyn_cast<MDString>(MDO);
assert(Args.size() == 0 && "too many arguments for MDString");
@@ -444,10 +442,7 @@ static bool storeToSameAddress(ScalarEvolution *SE, StoreInst *A,
return true;
// Otherwise compare address SCEVs
- if (SE->getSCEV(APtr) == SE->getSCEV(BPtr))
- return true;
-
- return false;
+ return SE->getSCEV(APtr) == SE->getSCEV(BPtr);
}
int LoopVectorizationLegality::isConsecutivePtr(Type *AccessTy,
@@ -734,26 +729,21 @@ bool LoopVectorizationLegality::setupOuterLoopInductions() {
BasicBlock *Header = TheLoop->getHeader();
// Returns true if a given Phi is a supported induction.
- auto isSupportedPhi = [&](PHINode &Phi) -> bool {
+ auto IsSupportedPhi = [&](PHINode &Phi) -> bool {
InductionDescriptor ID;
if (InductionDescriptor::isInductionPHI(&Phi, TheLoop, PSE, ID) &&
ID.getKind() == InductionDescriptor::IK_IntInduction) {
addInductionPhi(&Phi, ID, AllowedExit);
return true;
- } else {
- // Bail out for any Phi in the outer loop header that is not a supported
- // induction.
- LLVM_DEBUG(
- dbgs()
- << "LV: Found unsupported PHI for outer loop vectorization.\n");
- return false;
}
+ // Bail out for any Phi in the outer loop header that is not a supported
+ // induction.
+ LLVM_DEBUG(
+ dbgs() << "LV: Found unsupported PHI for outer loop vectorization.\n");
+ return false;
};
- if (llvm::all_of(Header->phis(), isSupportedPhi))
- return true;
- else
- return false;
+ return llvm::all_of(Header->phis(), IsSupportedPhi);
}
/// Checks if a function is scalarizable according to the TLI, in
@@ -837,13 +827,13 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
// historical vectorizer behavior after a generalization of the
// IVDescriptor code. The intent is to remove this check, but we
// have to fix issues around code quality for such loops first.
- auto isDisallowedStridedPointerInduction =
- [](const InductionDescriptor &ID) {
- if (AllowStridedPointerIVs)
- return false;
- return ID.getKind() == InductionDescriptor::IK_PtrInduction &&
- ID.getConstIntStepValue() == nullptr;
- };
+ auto IsDisallowedStridedPointerInduction =
+ [](const InductionDescriptor &ID) {
+ if (AllowStridedPointerIVs)
+ return false;
+ return ID.getKind() == InductionDescriptor::IK_PtrInduction &&
+ ID.getConstIntStepValue() == nullptr;
+ };
// TODO: Instead of recording the AllowedExit, it would be good to
// record the complementary set: NotAllowedExit. These include (but may
@@ -861,7 +851,7 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
// of these NotAllowedExit.
InductionDescriptor ID;
if (InductionDescriptor::isInductionPHI(Phi, TheLoop, PSE, ID) &&
- !isDisallowedStridedPointerInduction(ID)) {
+ !IsDisallowedStridedPointerInduction(ID)) {
addInductionPhi(Phi, ID, AllowedExit);
Requirements->addExactFPMathInst(ID.getExactFPMathInst());
continue;
@@ -876,7 +866,7 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
// As a last resort, coerce the PHI to a AddRec expression
// and re-try classifying it a an induction PHI.
if (InductionDescriptor::isInductionPHI(Phi, TheLoop, PSE, ID, true) &&
- !isDisallowedStridedPointerInduction(ID)) {
+ !IsDisallowedStridedPointerInduction(ID)) {
addInductionPhi(Phi, ID, AllowedExit);
continue;
}
@@ -932,9 +922,10 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
if (CI) {
auto *SE = PSE.getSE();
Intrinsic::ID IntrinID = getVectorIntrinsicIDForCall(CI, TLI);
- for (unsigned i = 0, e = CI->arg_size(); i != e; ++i)
- if (isVectorIntrinsicWithScalarOpAtArg(IntrinID, i)) {
- if (!SE->isLoopInvariant(PSE.getSCEV(CI->getOperand(i)), TheLoop)) {
+ for (unsigned Idx = 0; Idx < CI->arg_size(); ++Idx)
+ if (isVectorIntrinsicWithScalarOpAtArg(IntrinID, Idx)) {
+ if (!SE->isLoopInvariant(PSE.getSCEV(CI->getOperand(Idx)),
+ TheLoop)) {
reportVectorizationFailure("Found unvectorizable intrinsic",
"intrinsic instruction cannot be vectorized",
"CantVectorizeIntrinsic", ORE, TheLoop, CI);
@@ -1035,14 +1026,14 @@ bool LoopVectorizationLegality::canVectorizeInstrs() {
"loop induction variable could not be identified",
"NoInductionVariable", ORE, TheLoop);
return false;
- } else if (!WidestIndTy) {
+ }
+ if (!WidestIndTy) {
reportVectorizationFailure("Did not find one integer induction var",
"integer loop induction variable could not be identified",
"NoIntegerInductionVariable", ORE, TheLoop);
return false;
- } else {
- LLVM_DEBUG(dbgs() << "LV: Did not find one integer induction var.\n");
}
+ LLVM_DEBUG(dbgs() << "LV: Did not find one integer induction var.\n");
}
// Now we know the widest induction type, check if our found induction
@@ -1154,8 +1145,7 @@ bool LoopVectorizationLegality::canVectorizeMemory() {
}
}
- PSE.addPredicate(LAI->getPSE().getPredicate());
- return true;
+ return PSE.addPredicate(LAI->getPSE().getPredicate()), true;
}
bool LoopVectorizationLegality::canVectorizeFPMath(
|
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.
Would be good to update the title to be clear this fixes style issues
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.
LGTM
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.
LGTM, thanks!
Summary: Test Plan: Reviewers: Subscribers: Tasks: Tags: Differential Revision: https://phabricator.intern.facebook.com/D60250587
No description provided.