[PATCH] D115653: [DAG]Introduce llvm::processShuffleMasks and use it for shuffles in DAG Type Legalizer.

Alexey Bataev via Phabricator via llvm-commits llvm-commits at lists.llvm.org
Fri Mar 11 10:48:20 PST 2022


ABataev added a comment.

In D115653#3375670 <https://reviews.llvm.org/D115653#3375670>, @spatel wrote:

> I had never looked at the existing code, and I find that confusing already, so some high-level questions:
>
> 1. For legalization, it seems like the code was written with the potential to split by more than a factor of 2, but that can't happen with the current interface (hard-coded to output Lo and Hi halves). Is the new code intended to allow splitting by >2?

Yes, that was the idea.

> 2. In SDAG, we always have equal size input/output vector for shuffle node. Is the new code planned to be used with the IR version of shuffles (where input vectors may have different size than output)?

Yes.

> 3. IIUC, the interesting case is when we need to shuffle together from >2 inputs. Would it make sense to handle the easy cases (0,1,2 inputs) in a separate function?
>
> For example for #3, I think we could handle the simplest (NoInput) pattern before the main loop with something like:
>
>   unsigned MaskSize = N->getMask().size();
>   ArrayRef<int> LoMask = N->getMask().drop_back(NewElts);
>   if (all_of(LoMask, [MaskSize](int MaskElt) { return (unsigned)MaskElt >= MaskSize * 2; })) {
>     Lo = DAG.getUNDEF(NewVT);
>   }
>   ArrayRef<int> HiMask = N->getMask().drop_front(NewElts);
>   if (all_of(HiMask, [MaskSize](int MaskElt) { return (unsigned)MaskElt >= MaskSize * 2; })) {
>     Hi = DAG.getUNDEF(NewVT);
>   }

If I understood your question correctly, NoInputAction, SingleInputAction and ManyInputsAction params are exactly for this.


Repository:
  rG LLVM Github Monorepo

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

https://reviews.llvm.org/D115653



More information about the llvm-commits mailing list