[SLP] Remove TTI parameter from vectorizeHorReduction and vectorizeRootInstruction. NFC.

Since TTI is a member variable.
This commit is contained in:
Jim Lin 2024-10-16 15:38:06 +08:00
parent 6ffd3bbcd7
commit 5e9166e02a
2 changed files with 11 additions and 14 deletions

View File

@ -122,15 +122,13 @@ private:
/// or a horizontal reduction was not matched or not possible. /// or a horizontal reduction was not matched or not possible.
bool vectorizeHorReduction(PHINode *P, Instruction *Root, BasicBlock *BB, bool vectorizeHorReduction(PHINode *P, Instruction *Root, BasicBlock *BB,
slpvectorizer::BoUpSLP &R, slpvectorizer::BoUpSLP &R,
TargetTransformInfo *TTI,
SmallVectorImpl<WeakTrackingVH> &PostponedInsts); SmallVectorImpl<WeakTrackingVH> &PostponedInsts);
/// Make an attempt to vectorize reduction and then try to vectorize /// Make an attempt to vectorize reduction and then try to vectorize
/// postponed binary operations. /// postponed binary operations.
/// \returns true on any successfull vectorization. /// \returns true on any successfull vectorization.
bool vectorizeRootInstruction(PHINode *P, Instruction *Root, BasicBlock *BB, bool vectorizeRootInstruction(PHINode *P, Instruction *Root, BasicBlock *BB,
slpvectorizer::BoUpSLP &R, slpvectorizer::BoUpSLP &R);
TargetTransformInfo *TTI);
/// Try to vectorize trees that start at insertvalue instructions. /// Try to vectorize trees that start at insertvalue instructions.
bool vectorizeInsertValueInst(InsertValueInst *IVI, BasicBlock *BB, bool vectorizeInsertValueInst(InsertValueInst *IVI, BasicBlock *BB,

View File

@ -19949,7 +19949,7 @@ static bool isReductionCandidate(Instruction *I) {
} }
bool SLPVectorizerPass::vectorizeHorReduction( bool SLPVectorizerPass::vectorizeHorReduction(
PHINode *P, Instruction *Root, BasicBlock *BB, BoUpSLP &R, TargetTransformInfo *TTI, PHINode *P, Instruction *Root, BasicBlock *BB, BoUpSLP &R,
SmallVectorImpl<WeakTrackingVH> &PostponedInsts) { SmallVectorImpl<WeakTrackingVH> &PostponedInsts) {
if (!ShouldVectorizeHor) if (!ShouldVectorizeHor)
return false; return false;
@ -19982,7 +19982,7 @@ bool SLPVectorizerPass::vectorizeHorReduction(
Stack.emplace(SelectRoot(), 0); Stack.emplace(SelectRoot(), 0);
SmallPtrSet<Value *, 8> VisitedInstrs; SmallPtrSet<Value *, 8> VisitedInstrs;
bool Res = false; bool Res = false;
auto &&TryToReduce = [this, TTI, &R](Instruction *Inst) -> Value * { auto &&TryToReduce = [this, &R](Instruction *Inst) -> Value * {
if (R.isAnalyzedReductionRoot(Inst)) if (R.isAnalyzedReductionRoot(Inst))
return nullptr; return nullptr;
if (!isReductionCandidate(Inst)) if (!isReductionCandidate(Inst))
@ -20049,10 +20049,9 @@ bool SLPVectorizerPass::vectorizeHorReduction(
} }
bool SLPVectorizerPass::vectorizeRootInstruction(PHINode *P, Instruction *Root, bool SLPVectorizerPass::vectorizeRootInstruction(PHINode *P, Instruction *Root,
BasicBlock *BB, BoUpSLP &R, BasicBlock *BB, BoUpSLP &R) {
TargetTransformInfo *TTI) {
SmallVector<WeakTrackingVH> PostponedInsts; SmallVector<WeakTrackingVH> PostponedInsts;
bool Res = vectorizeHorReduction(P, Root, BB, R, TTI, PostponedInsts); bool Res = vectorizeHorReduction(P, Root, BB, R, PostponedInsts);
Res |= tryToVectorize(PostponedInsts, R); Res |= tryToVectorize(PostponedInsts, R);
return Res; return Res;
} }
@ -20317,7 +20316,7 @@ bool SLPVectorizerPass::vectorizeCmpInsts(iterator_range<ItT> CmpInsts,
continue; continue;
for (Value *Op : I->operands()) for (Value *Op : I->operands())
if (auto *RootOp = dyn_cast<Instruction>(Op)) if (auto *RootOp = dyn_cast<Instruction>(Op))
Changed |= vectorizeRootInstruction(nullptr, RootOp, BB, R, TTI); Changed |= vectorizeRootInstruction(nullptr, RootOp, BB, R);
} }
// Try to vectorize operands as vector bundles. // Try to vectorize operands as vector bundles.
for (CmpInst *I : CmpInsts) { for (CmpInst *I : CmpInsts) {
@ -20384,7 +20383,7 @@ bool SLPVectorizerPass::vectorizeInserts(InstSetVector &Instructions,
// pass2 - try to vectorize reductions only // pass2 - try to vectorize reductions only
if (R.isDeleted(I)) if (R.isDeleted(I))
continue; continue;
OpsChanged |= vectorizeHorReduction(nullptr, I, BB, R, TTI, PostponedInsts); OpsChanged |= vectorizeHorReduction(nullptr, I, BB, R, PostponedInsts);
if (R.isDeleted(I) || isa<CmpInst>(I)) if (R.isDeleted(I) || isa<CmpInst>(I))
continue; continue;
// pass3 - try to match and vectorize a buildvector sequence. // pass3 - try to match and vectorize a buildvector sequence.
@ -20644,7 +20643,7 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
if (P->getNumIncomingValues() == 2) { if (P->getNumIncomingValues() == 2) {
// Try to match and vectorize a horizontal reduction. // Try to match and vectorize a horizontal reduction.
Instruction *Root = getReductionInstr(DT, P, BB, LI); Instruction *Root = getReductionInstr(DT, P, BB, LI);
if (Root && vectorizeRootInstruction(P, Root, BB, R, TTI)) { if (Root && vectorizeRootInstruction(P, Root, BB, R)) {
Changed = true; Changed = true;
It = BB->begin(); It = BB->begin();
E = BB->end(); E = BB->end();
@ -20666,8 +20665,8 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
// vectorization. // vectorization.
if (auto *PI = dyn_cast<Instruction>(P->getIncomingValue(I)); if (auto *PI = dyn_cast<Instruction>(P->getIncomingValue(I));
PI && !IsInPostProcessInstrs(PI)) { PI && !IsInPostProcessInstrs(PI)) {
bool Res = vectorizeRootInstruction(nullptr, PI, bool Res =
P->getIncomingBlock(I), R, TTI); vectorizeRootInstruction(nullptr, PI, P->getIncomingBlock(I), R);
Changed |= Res; Changed |= Res;
if (Res && R.isDeleted(P)) { if (Res && R.isDeleted(P)) {
It = BB->begin(); It = BB->begin();
@ -20701,7 +20700,7 @@ bool SLPVectorizerPass::vectorizeChainsInBlock(BasicBlock *BB, BoUpSLP &R) {
if (auto *VI = dyn_cast<Instruction>(V); if (auto *VI = dyn_cast<Instruction>(V);
VI && !IsInPostProcessInstrs(VI)) VI && !IsInPostProcessInstrs(VI))
// Try to match and vectorize a horizontal reduction. // Try to match and vectorize a horizontal reduction.
OpsChanged |= vectorizeRootInstruction(nullptr, VI, BB, R, TTI); OpsChanged |= vectorizeRootInstruction(nullptr, VI, BB, R);
} }
} }
// Start vectorization of post-process list of instructions from the // Start vectorization of post-process list of instructions from the