[llvm] [VPlan] Permit more users in narrowToSingleScalars (PR #166559)

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 5 10:22:41 PST 2025


================
@@ -1411,10 +1412,14 @@ static void narrowToSingleScalarRecipes(VPlan &Plan) {
       // broadcasts.
       if (!vputils::isSingleScalar(RepOrWidenR) ||
           !all_of(RepOrWidenR->users(), [RepOrWidenR](const VPUser *U) {
-            return U->usesScalars(RepOrWidenR) ||
-                   match(cast<VPRecipeBase>(U),
-                         m_CombineOr(m_ExtractLastElement(m_VPValue()),
-                                     m_ExtractLastLanePerPart(m_VPValue())));
+            if (isa<VPWidenStoreRecipe>(U))
+              return true;
+
+            if (auto *VPI = dyn_cast<VPInstruction>(U))
+              if (VPI->isVectorToScalar() || VPI->isSingleScalar())
----------------
artagnon wrote:

> Although from the test diff even introducing the broadcast seems to be profitable, at least for the case where the user is a widened store.

There is a trick here though: the store's operand, RepR, is already determined to be single-scalar.

https://github.com/llvm/llvm-project/pull/166559


More information about the llvm-commits mailing list