[llvm] [VPlan] Introduce chainUsesScalarValues (PR #158377)
Ramkumar Ramachandra via llvm-commits
llvm-commits at lists.llvm.org
Mon Sep 29 09:15:07 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))
----------------
artagnon wrote:
Unfortunately, vputils::isSingleScalar is a bit too powerful, and returns true when the argument is indirectly a single-scalar. Sorry, we're specifically checking for VPWidenStoreRecipe: will fix, but the reason is that it is always profitable to widen stores, even if it's uniform across all lanes; it is an important leaf condition in chainUsesScalarValues, as it has no users, and therefore, any single-scalar addresses or stored-values should be narrowed, allowing the entire chain of uses to be narrowed.
https://github.com/llvm/llvm-project/pull/158377
More information about the llvm-commits
mailing list