Skip to content

Commit 0db57ab

Browse files
authored
[VPlan] Improve code using onlyScalarValuesUsed (NFC) (#154564)
1 parent 484d040 commit 0db57ab

File tree

2 files changed

+3
-11
lines changed

2 files changed

+3
-11
lines changed

llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -557,11 +557,7 @@ SmallVector<VPRegisterUsage, 8> llvm::calculateRegisterUsageForPlan(
557557
isa<VPCanonicalIVPHIRecipe, VPReplicateRecipe, VPDerivedIVRecipe,
558558
VPScalarIVStepsRecipe>(R) ||
559559
(isa<VPInstruction>(R) &&
560-
all_of(cast<VPSingleDefRecipe>(R)->users(),
561-
[&](VPUser *U) {
562-
return cast<VPRecipeBase>(U)->usesScalars(
563-
R->getVPSingleValue());
564-
})) ||
560+
vputils::onlyScalarValuesUsed(cast<VPSingleDefRecipe>(R))) ||
565561
(isa<VPReductionPHIRecipe>(R) &&
566562
(cast<VPReductionPHIRecipe>(R))->isInLoop())) {
567563
unsigned ClassID = TTI.getRegisterClassForType(
@@ -614,9 +610,7 @@ SmallVector<VPRegisterUsage, 8> llvm::calculateRegisterUsageForPlan(
614610
for (auto *In : LoopInvariants) {
615611
// FIXME: The target might use more than one register for the type
616612
// even in the scalar case.
617-
bool IsScalar = all_of(In->users(), [&](VPUser *U) {
618-
return cast<VPRecipeBase>(U)->usesScalars(In);
619-
});
613+
bool IsScalar = vputils::onlyScalarValuesUsed(In);
620614

621615
ElementCount VF = IsScalar ? ElementCount::getFixed(1) : VFs[Idx];
622616
unsigned ClassID = TTI.getRegisterClassForType(

llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2980,9 +2980,7 @@ bool VPReplicateRecipe::shouldPack() const {
29802980
// VPPredInstPHIRecipe. In this case, also pack the scalar values in a vector.
29812981
return any_of(users(), [](const VPUser *U) {
29822982
if (auto *PredR = dyn_cast<VPPredInstPHIRecipe>(U))
2983-
return any_of(PredR->users(), [PredR](const VPUser *U) {
2984-
return !U->usesScalars(PredR);
2985-
});
2983+
return !vputils::onlyScalarValuesUsed(PredR);
29862984
return false;
29872985
});
29882986
}

0 commit comments

Comments
 (0)