[PATCH] D115811: [SLP]Early exit out of the reordering if shuffled/perfect diamond match found.

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Wed Dec 15 14:46:13 PST 2021


ABataev added inline comments.


================
Comment at: llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp:1656-1665
+        SmallPtrSet<Value *, 4> UniqueValues;
+        ArrayRef<OperandData> Op0 = OpsVec.front();
+        for (const OperandData &Data : Op0)
+          UniqueValues.insert(Data.V);
+        for (ArrayRef<OperandData> Op : drop_begin(OpsVec, 1)) {
+          if (any_of(Op, [&UniqueValues](const OperandData &Data) {
+                return !UniqueValues.contains(Data.V);
----------------
ABataev wrote:
> vporpo wrote:
> > ABataev wrote:
> > > vporpo wrote:
> > > > Isn't `VLOperands` a better place for this logic? Perhaps a method like: `isDiamondMatch()` ?
> > > > This will also help separate the temporary check `UniqueValues.size() == 2 || !isPowerOf2_32(UniqueValues.size())`. What do you think?
> > > I just thought that we may have this situation after the very first iteration of the reordering, not only initially. 
> > I am not sure I follow why moving this logic to a member method in VLOperands won't work in this case. Could you elaborate a bit on this?
> I have the same problem because this function `reorder()` is a member of `VLOperands` class :)
Or do you suggest transforming this lambda to a member function? If so, I think keeping lambda is better because it does not increase the number of interfaces of the class. If (or when) we'll have several users of this functionality, it can be outlined into a private member function.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115811



More information about the llvm-commits mailing list