[PATCH] D92668: [SLP]Merge reorder and reuse shuffles.

Anton Afanasyev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Dec 4 14:09:32 PST 2020


anton-afanasyev added a comment.

The same work will be done by instcombine, so we can just zero redundant cost here to gain the same effect globally. But it makes sense to make shuffle merging at the vectorization stage as well, of course.



================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3510
         }
       }
       int DeadCost = ReuseShuffleCost;
----------------



================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:3513
+      if (!NeedToShuffleReuses && !E->ReorderIndices.empty())
         DeadCost += TTI->getShuffleCost(
             TargetTransformInfo::SK_PermuteSingleSrc, VecTy);
----------------
Here `+=` looks confusing, we can just set `DeadCost = ...`, since `DeadCost == 0`.


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4348
+      return V;
+    IsFinalized = true;
+    return Builder.CreateShuffleVector(V, Mask, "shuffle");
----------------
This doesn't change anything but it looks preferable for `IsFinalized` to be true after finalization even for empty `Mask`.


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:4634
-      if (NeedToShuffleReuses)
-        V = Builder.CreateShuffleVector(V, E->ReuseShuffleIndices, "shuffle");
 
----------------
Why do we ignore `ReuseShuffleIndices` here?


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D92668/new/

https://reviews.llvm.org/D92668



More information about the llvm-commits mailing list