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

Florian Hahn via llvm-commits llvm-commits at lists.llvm.org
Fri Nov 7 04:15:16 PST 2025


================
@@ -1419,10 +1419,22 @@ 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 (auto *Store = dyn_cast<VPWidenStoreRecipe>(U)) {
+              // The assert must hold as we checked the RepOrWidenR operand
+              // against vputils::isSingleScalar.
+              assert(RepOrWidenR == Store->getAddr() ||
+                     vputils::isSingleScalar(Store->getStoredValue()));
+              return true;
+            }
----------------
fhahn wrote:

%x needs to be a single-scalar. We process in reverse order, so %b should be narrowed first (only used by wide store), then %a should be narrowed(only used by single-scalar and wide store). For this case, I'd expect we need broadcasts for %a and %b to serve the stores

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


More information about the llvm-commits mailing list