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

Ramkumar Ramachandra via llvm-commits llvm-commits at lists.llvm.org
Wed Nov 5 08:14:29 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:

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

I think the check is a bit ad-hoc in the first place: usesScalars is unfortunately too restricting.

> Do we get many regressions if we remove the restrictions on the users entirely?

Without the users restriction, we get lot of regressions.

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


More information about the llvm-commits mailing list