[llvm] [SLP][NFC] Remove useless code of deleting ExtractElementInst (PR #106697)
Alexey Bataev via llvm-commits
llvm-commits at lists.llvm.org
Fri Aug 30 08:38:38 PDT 2024
alexey-bataev wrote:
> > > > > The extractelements of buildvector must be the operators of vectorized scalars. Then it will be removed by removeInstructionsAndOperands . Is there any exception?
> > > >
> > > >
> > > > Some of them, which we can prove they can be vectorized, are vectorized and removed by removeInstructionsAndOperands. But not all combinations of the extractelements can be handled by the SLP vectorizer and transformed into shuffles, some of them remain as extractelement/insertelement sequences. And only adjustExtracts knows which ones of the gathered extractelements can be safely removed as vectorized.
> > > > E.g., node <extractelement v1, extractelement v2, extractelement v3, load> will be gathered. First 2 extractelements can be vectorized as shuffle and will be removed by adjustExtracts. The 3rd one, extractelement v3, will currently remain as is and won't be removed.
> > >
> > >
> > > Sorry for wasting your time again. I rechecked the logic of the code. The `adjustExtracts` function removes `ExtractElementInst` under certain conditions as outlined below:
> > >
> > > 1. `ExtractElementInst` has one use.
> > > 2. `R.getTreeEntry(U)`, meaning the user of `EI` must be vectorized.
> > > 3. `R.MultiNodeScalars.contains(U)`, where the user must not be in a multi-vectorized node.
> > > 4. Other more strict conditions, and so on.
> > >
> > > For the `removeInstructionsAndOperands` function, if an `EI` matches the conditions of 1 to 3 above, it will be removed.
> >
> >
> > What is the question?
>
> My point is that the `adjustExtracts` function does not need to remove EI. Because removeInstructionsAndOperands can handle it. All the conditions of `adjustExtracts` are satisfied by `removeInstructionsAndOperands`.
removeInstructionsAndOperands is called only for the scalars, which are part of the vectorized nodes. Gathered nodes processed separately. You mean the extractelement can be included in the list of the vectorized nodes? Yes, but adjustExtracts should do this, because other functions do not have information about this. And it does this already by calling R.eraseInstruction(EI)
https://github.com/llvm/llvm-project/pull/106697
More information about the llvm-commits
mailing list