[llvm] [SLP][Revec] Fix SLP crash when trying to fold trailing scalars into the reduced value (PR #203477)

Alexey Bataev via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 04:08:24 PDT 2026


================
@@ -30275,11 +30275,26 @@ class HorizontalReduction {
     // Emit ordered reduction for the vectorized window.
     Builder.SetCurrentDebugLocation(
         cast<Instruction>(ReductionRoot)->getDebugLoc());
-    if (VectorizedTree)
+    if (auto *VecTy = dyn_cast<FixedVectorType>(DestTy);
+        SLPReVec && VecTy && SuccessRoot) {
+      unsigned DestTyNumElements = getNumElements(VecTy);
+      unsigned VF = getNumElements(SuccessRoot->getType()) / DestTyNumElements;
+      for (auto I : seq<unsigned>(VF)) {
+        auto Position = I * DestTyNumElements;
----------------
alexey-bataev wrote:

`unsigned Position = `

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


More information about the llvm-commits mailing list