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

Sushant Gokhale via llvm-commits llvm-commits at lists.llvm.org
Tue Jun 2 04:15:27 PDT 2026


sushgokh wrote:

> Something like should help:
> 
> ```
> --- a/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
> +++ b/llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp
> @@ -17949,6 +17949,19 @@ bool BoUpSLP::isTreeTinyAndNotFullyVectorizable(bool ForReduction) const {
>      return true;
>    }
> 
> +  if (SLPReVec && ForReduction && VectorizableTree.size() == 3 &&
> +      VectorizableTree[0]->State == TreeEntry::Vectorize &&
> +      VectorizableTree[0]->getOpcode() == Instruction::ShuffleVector &&
> +      VectorizableTree[1]->isGather() &&
> +      isSplat(VectorizableTree[1]->Scalars) && VectorizableTree[2]->isGather() &&
> +      allConstant(VectorizableTree[2]->Scalars)) {
> +    LLVM_DEBUG(
> +        dbgs()
> +        << "SLP: rejecting reduction tree with 3 nodes (1st - shuffle and the "
> +           "second and the third nodes are gathers).\n");
> +    return true;
> +  }
> +
> ```

Thanks @alexey-bataev Added this patch. 

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


More information about the llvm-commits mailing list