Skip to content

Commit 90c8229

Browse files
author
GYT
committed
Clang-format loop vectorizer
1 parent 5719fb8 commit 90c8229

File tree

2 files changed

+101
-89
lines changed

2 files changed

+101
-89
lines changed

llvm/lib/Transforms/Vectorize/LoopVectorizationLegality.cpp

Lines changed: 28 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -40,10 +40,10 @@ static cl::opt<bool>
4040
EnableIfConversion("enable-if-conversion", cl::init(true), cl::Hidden,
4141
cl::desc("Enable if-conversion during vectorization."));
4242

43-
static cl::opt<bool>
44-
AllowStridedPointerIVs("lv-strided-pointer-ivs", cl::init(false), cl::Hidden,
45-
cl::desc("Enable recognition of non-constant strided "
46-
"pointer induction variables."));
43+
static cl::opt<bool> AllowStridedPointerIVs(
44+
"lv-strided-pointer-ivs", cl::init(false), cl::Hidden,
45+
cl::desc("Enable recognition of non-constant strided "
46+
"pointer induction variables."));
4747

4848
static cl::opt<bool>
4949
HintsAllowReordering("hints-allow-reordering", cl::init(true), cl::Hidden,
@@ -420,8 +420,8 @@ static IntegerType *getWiderInductionTy(const DataLayout &DL, Type *Ty0,
420420
/// identified reduction variable.
421421
static bool hasOutsideLoopUser(const Loop *TheLoop, Instruction *Inst,
422422
SmallPtrSetImpl<Value *> &AllowedExit) {
423-
// Reductions, Inductions and non-header phis are allowed to have exit users. All
424-
// other instructions must not have external users.
423+
// Reductions, Inductions and non-header phis are allowed to have exit users.
424+
// All other instructions must not have external users.
425425
if (!AllowedExit.count(Inst))
426426
// Check that all of the users of the loop are inside the BB.
427427
for (User *U : Inst->users()) {
@@ -459,12 +459,13 @@ int LoopVectorizationLegality::isConsecutivePtr(Type *AccessTy,
459459
// pointer is checked to reference consecutive elements suitable for a
460460
// masked access.
461461
const auto &Strides =
462-
LAI ? LAI->getSymbolicStrides() : DenseMap<Value *, const SCEV *>();
462+
LAI ? LAI->getSymbolicStrides() : DenseMap<Value *, const SCEV *>();
463463

464464
bool CanAddPredicate = !llvm::shouldOptimizeForSize(
465465
TheLoop->getHeader(), PSI, BFI, PGSOQueryType::IRPass);
466-
int Stride = getPtrStride(PSE, AccessTy, Ptr, TheLoop, Strides,
467-
CanAddPredicate, false).value_or(0);
466+
int Stride =
467+
getPtrStride(PSE, AccessTy, Ptr, TheLoop, Strides, CanAddPredicate, false)
468+
.value_or(0);
468469
if (Stride == 1 || Stride == -1)
469470
return Stride;
470471
return 0;
@@ -622,7 +623,8 @@ bool LoopVectorizationLegality::canVectorizeOuterLoop() {
622623
// not supported yet.
623624
auto *Br = dyn_cast<BranchInst>(BB->getTerminator());
624625
if (!Br) {
625-
reportVectorizationFailure("Unsupported basic block terminator",
626+
reportVectorizationFailure(
627+
"Unsupported basic block terminator",
626628
"loop control flow is not understood by vectorizer",
627629
"CFGNotUnderstood", ORE, TheLoop);
628630
if (DoExtraAnalysis)
@@ -641,7 +643,8 @@ bool LoopVectorizationLegality::canVectorizeOuterLoop() {
641643
!TheLoop->isLoopInvariant(Br->getCondition()) &&
642644
!LI->isLoopHeader(Br->getSuccessor(0)) &&
643645
!LI->isLoopHeader(Br->getSuccessor(1))) {
644-
reportVectorizationFailure("Unsupported conditional branch",
646+
reportVectorizationFailure(
647+
"Unsupported conditional branch",
645648
"loop control flow is not understood by vectorizer",
646649
"CFGNotUnderstood", ORE, TheLoop);
647650
if (DoExtraAnalysis)
@@ -655,9 +658,10 @@ bool LoopVectorizationLegality::canVectorizeOuterLoop() {
655658
// simple outer loops scenarios with uniform nested loops.
656659
if (!isUniformLoopNest(TheLoop /*loop nest*/,
657660
TheLoop /*context outer loop*/)) {
658-
reportVectorizationFailure("Outer loop contains divergent loops",
659-
"loop control flow is not understood by vectorizer",
660-
"CFGNotUnderstood", ORE, TheLoop);
661+
reportVectorizationFailure(
662+
"Outer loop contains divergent loops",
663+
"loop control flow is not understood by vectorizer", "CFGNotUnderstood",
664+
ORE, TheLoop);
661665
if (DoExtraAnalysis)
662666
Result = false;
663667
else
@@ -1623,9 +1627,10 @@ bool LoopVectorizationLegality::canVectorizeLoopCFG(Loop *Lp,
16231627
// We must have a loop in canonical form. Loops with indirectbr in them cannot
16241628
// be canonicalized.
16251629
if (!Lp->getLoopPreheader()) {
1626-
reportVectorizationFailure("Loop doesn't have a legal pre-header",
1627-
"loop control flow is not understood by vectorizer",
1628-
"CFGNotUnderstood", ORE, TheLoop);
1630+
reportVectorizationFailure(
1631+
"Loop doesn't have a legal pre-header",
1632+
"loop control flow is not understood by vectorizer", "CFGNotUnderstood",
1633+
ORE, TheLoop);
16291634
if (DoExtraAnalysis)
16301635
Result = false;
16311636
else
@@ -1634,9 +1639,10 @@ bool LoopVectorizationLegality::canVectorizeLoopCFG(Loop *Lp,
16341639

16351640
// We must have a single backedge.
16361641
if (Lp->getNumBackEdges() != 1) {
1637-
reportVectorizationFailure("The loop must have a single backedge",
1638-
"loop control flow is not understood by vectorizer",
1639-
"CFGNotUnderstood", ORE, TheLoop);
1642+
reportVectorizationFailure(
1643+
"The loop must have a single backedge",
1644+
"loop control flow is not understood by vectorizer", "CFGNotUnderstood",
1645+
ORE, TheLoop);
16401646
if (DoExtraAnalysis)
16411647
Result = false;
16421648
else
@@ -2049,7 +2055,8 @@ bool LoopVectorizationLegality::canVectorize(bool UseVPlanNativePath) {
20492055
if (PSE.getPredicate().getComplexity() > SCEVThreshold) {
20502056
LLVM_DEBUG(dbgs() << "LV: Vectorization not profitable "
20512057
"due to SCEVThreshold");
2052-
reportVectorizationFailure("Too many SCEV checks needed",
2058+
reportVectorizationFailure(
2059+
"Too many SCEV checks needed",
20532060
"Too many SCEV assumptions need to be made and checked at runtime",
20542061
"TooManySCEVRunTimeChecks", ORE, TheLoop);
20552062
if (DoExtraAnalysis)

0 commit comments

Comments
 (0)