[llvm] [VPlan] Improve code using onlyScalarValuesUsed (NFC) (PR #154564)
via llvm-commits
llvm-commits at lists.llvm.org
Wed Aug 20 08:42:17 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-vectorizers
@llvm/pr-subscribers-llvm-transforms
Author: Ramkumar Ramachandra (artagnon)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/154564.diff
2 Files Affected:
- (modified) llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp (+2-8)
- (modified) llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp (+1-3)
``````````diff
diff --git a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
index b39231f106300..716814b84f487 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanAnalysis.cpp
@@ -557,11 +557,7 @@ SmallVector<VPRegisterUsage, 8> llvm::calculateRegisterUsageForPlan(
isa<VPCanonicalIVPHIRecipe, VPReplicateRecipe, VPDerivedIVRecipe,
VPScalarIVStepsRecipe>(R) ||
(isa<VPInstruction>(R) &&
- all_of(cast<VPSingleDefRecipe>(R)->users(),
- [&](VPUser *U) {
- return cast<VPRecipeBase>(U)->usesScalars(
- R->getVPSingleValue());
- })) ||
+ vputils::onlyScalarValuesUsed(cast<VPSingleDefRecipe>(R))) ||
(isa<VPReductionPHIRecipe>(R) &&
(cast<VPReductionPHIRecipe>(R))->isInLoop())) {
unsigned ClassID = TTI.getRegisterClassForType(
@@ -614,9 +610,7 @@ SmallVector<VPRegisterUsage, 8> llvm::calculateRegisterUsageForPlan(
for (auto *In : LoopInvariants) {
// FIXME: The target might use more than one register for the type
// even in the scalar case.
- bool IsScalar = all_of(In->users(), [&](VPUser *U) {
- return cast<VPRecipeBase>(U)->usesScalars(In);
- });
+ bool IsScalar = vputils::onlyScalarValuesUsed(In);
ElementCount VF = IsScalar ? ElementCount::getFixed(1) : VFs[Idx];
unsigned ClassID = TTI.getRegisterClassForType(
diff --git a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
index 7ca9b230f5aae..f3a188158adbe 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
+++ b/llvm/lib/Transforms/Vectorize/VPlanRecipes.cpp
@@ -2958,9 +2958,7 @@ bool VPReplicateRecipe::shouldPack() const {
// VPPredInstPHIRecipe. In this case, also pack the scalar values in a vector.
return any_of(users(), [](const VPUser *U) {
if (auto *PredR = dyn_cast<VPPredInstPHIRecipe>(U))
- return any_of(PredR->users(), [PredR](const VPUser *U) {
- return !U->usesScalars(PredR);
- });
+ return !vputils::onlyScalarValuesUsed(PredR);
return false;
});
}
``````````
</details>
https://github.com/llvm/llvm-project/pull/154564
More information about the llvm-commits
mailing list