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

Luke Lau via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 5 08:09:33 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())
----------------
lukel97 wrote:

I think isVectorToScalar will also include things like `VPInstruction::ComputeReductionResult` which will need broadcasted. Which the comment above seems to want to avoid?

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. Do we get many regressions if we remove the restrictions on the users entirely?

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


More information about the llvm-commits mailing list