[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;
----------------
alexey-bataev wrote:

How it will work for non-power-of-2 number of elements? What if VF is 0?

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


More information about the llvm-commits mailing list