[llvm] [VPlan] Introduce chainUsesScalarValues (PR #158377)
David Sherwood via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 29 07:33:00 PDT 2025
================
@@ -30,6 +30,30 @@ bool vputils::onlyScalarValuesUsed(const VPValue *Def) {
[Def](const VPUser *U) { return U->usesScalars(Def); });
}
+bool vputils::chainUsesScalarValues(const VPValue *Root) {
+ SmallVector<std::pair<const VPValue *, const VPUser *>> Worklist;
+ for (const VPUser *V : Root->users())
+ Worklist.emplace_back(Root, V);
+ while (!Worklist.empty()) {
+ auto [Op, U] = Worklist.pop_back_val();
+ if (isa<VPWidenRecipe, VPWidenCastRecipe, VPWidenCallRecipe,
+ VPWidenGEPRecipe, VPWidenSelectRecipe, VPWidenIntrinsicRecipe>(U)) {
+ const VPValue *Def = cast<VPSingleDefRecipe>(U);
+ for (const VPUser *V : Def->users())
+ Worklist.emplace_back(Def, V);
+ continue;
+ }
+ if (isa<VPWidenMemoryRecipe>(U) && vputils::isSingleScalar(Op))
+ continue;
+ if (auto *VPI = dyn_cast<VPInstruction>(U))
+ if (VPI->isVectorToScalar() || VPI->isSingleScalar())
+ continue;
+ if (!U->usesScalars(Op))
----------------
david-arm wrote:
Looks like really you could just update the version of usesScalars in the VPInstruction class to return true when isVectorToScalar or isSingleScalar returns true?
https://github.com/llvm/llvm-project/pull/158377
More information about the llvm-commits
mailing list