[llvm] [SelectionDAG] Legalize non-divisible scalable vector widening (PR #218777)

Paul Walker via llvm-commits llvm-commits at lists.llvm.org
Wed Aug 26 03:53:11 PDT 2026


================
@@ -9242,6 +9242,32 @@ SDValue DAGTypeLegalizer::ModifyToType(SDValue InOp, EVT NVT,
   if (InEC.hasKnownScalarFactor(WidenEC))
     return DAG.getExtractSubvector(dl, NVT, InOp, 0);
 
+  if (InVT.isScalableVector()) {
+    // Split the input and widened vector into the largest equal-sized scalable
+    // subvectors. The common factor lets us preserve the source lanes and pad
+    // with subvectors, avoiding per-lane operations on scalable vectors.
+    // Worst case scenario (GCD == 1) we fall back to single operations.
----------------
paulwalker-arm wrote:

The common factor is less about preserving lanes and more a requirement when extracting the subvectors? The "single operations" part is misleading because these are scalable vectors, so "vscale x 1" is not a single element.

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


More information about the llvm-commits mailing list