[llvm] [SLP] Inefficient cost-modelling and codegen for reductions with slp-… (PR #197875)

Sushant Gokhale via llvm-commits llvm-commits at lists.llvm.org
Mon May 25 03:48:30 PDT 2026


================
@@ -27764,6 +27760,8 @@ class HorizontalReduction {
   ReductionOpsListType ReductionOps;
   /// List of possibly reduced values.
   SmallVector<SmallVector<Value *>> ReducedVals;
+  /// List of values to ignore while collecting reduction values.
+  inline static SmallDenseSet<Value *> IgnoredVals;
----------------
sushgokh wrote:

Consider this sequence:
1. [This ](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp#L30910)calls reduce
2. Step 1 marks the values to be ignored and also pushes the instruction on stack
3. The same API call, in step 1, creates new  `HorizontalReduction Rdx` [here](https://github.com/llvm/llvm-project/blob/main/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp#L30865) and we would lose the values to be ignored. 

These values need to persist  within the BB and hence static

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


More information about the llvm-commits mailing list