[llvm] [SLP]Add cost estimation for gather node reshuffling (PR #115201)

Matt Arsenault via llvm-commits llvm-commits at lists.llvm.org
Sat Nov 16 10:08:24 PST 2024


================
@@ -982,17 +982,35 @@ class BasicTTIImplBase : public TargetTransformInfoImplCRTPBase<T> {
       return Kind;
     int NumSrcElts = Ty->getElementCount().getKnownMinValue();
     switch (Kind) {
-    case TTI::SK_PermuteSingleSrc:
+    case TTI::SK_PermuteSingleSrc: {
       if (ShuffleVectorInst::isReverseMask(Mask, NumSrcElts))
         return TTI::SK_Reverse;
       if (ShuffleVectorInst::isZeroEltSplatMask(Mask, NumSrcElts))
         return TTI::SK_Broadcast;
+      // Check that the broadcast index meets at least twice.
+      bool IsCompared = false;
+      if (int SplatIdx = PoisonMaskElem;
+          all_of(Mask,
+                 [&](int Idx) {
+                   if (Idx == PoisonMaskElem)
+                     return true;
+                   if (SplatIdx == PoisonMaskElem) {
+                     SplatIdx = Idx;
+                     return true;
+                   }
+                   IsCompared = true;
+                   ;
+                   return SplatIdx == Idx;
+                 }) &&
+          IsCompared && SplatIdx != PoisonMaskElem)
----------------
arsenm wrote:

Can you just merge this into the all_of logic 

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


More information about the llvm-commits mailing list