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

Sushant Gokhale via llvm-commits llvm-commits at lists.llvm.org
Fri Jun 12 04:14:28 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;
----------------
sushgokh wrote:

would it make sense if I use `ReduxWidth` instead of `VF` ?

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


More information about the llvm-commits mailing list