This deprecates vectorizeSimpleInstructions() and replaces it with separate
functions that vectorize CmpInsts and Inserts.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
| llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
|---|---|---|
| 14708–14709 | It does not make it simpler | |
| 14740–14741 | Same | |
| 14749–14753 | You have to duplicate the same code, which is more complex than before | |
| llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
|---|---|---|
| 14749–14753 | The check for it->isTerminator() controls whether we vectorize CmpInsts. Hiding it within vectorizeSimpleInstructions is just confusing and makes it harder to read. | |
| llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
|---|---|---|
| 14749–14753 | You can try, but check that the logic does not become more complex than before. | |
| llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
|---|---|---|
| 14749–14753 | OK let me give it a try. | |
| llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
|---|---|---|
| 14651–14653 | Use dyn_cast: if (auto *Cmp = dyn_cast<CmpInst>(I)) return PostProcessCmps.contains(Cmp); return isa<InsertElementInst, InsertValueInst>(I) && PostProcessInserts.contains(I); | |
| llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h | ||
|---|---|---|
| 148–149 | Why need a template here since looks like it accepts only ArrayRef? | |
Using CmpInst * instead of Instruction * in the loops of vectorizeCmpInsts(). This makes it a bit more explicit that we are expecting a range of CmpInst *.
| llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h | ||
|---|---|---|
| 148–149 | We are passing an iterator_range and there is no ArrayRef constructor with an iterator_range argument. | |
| llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h | ||
|---|---|---|
| 148–149 | SmallSetVector class, used to store instruction, has getArrayRef() member function, which can return ArrayRef. | |
| llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h | ||
|---|---|---|
| 148–149 | I don't see how getting the ArrayRef from the SmallSetVector would help. We still need to pass an iterator_range as we need to iterate in reverse. | |
| llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h | ||
|---|---|---|
| 148–149 | Better to avoid template. Better to pass ArrayRef and reverse it there (adding the explanation, why need to do it). | |
| llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h | ||
|---|---|---|
| 148–149 | Reversing the iteration order in vectorizeCmpInsts is not a good solution, because no one expects that the function would walk the array in reverse. Using a range seems to be the best option here. This pattern with a template <typename RangeT> is being used in several other places throughout LLVM. I am not sure I understand why you don't like it. | |
| llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h | ||
|---|---|---|
| 148–149 | It just makes less obvous constraints and requirements for tje parameter, while ArrayRef explicitly provides it. Would be good somehow specify the expected constraints, like iterator_range<T> or something similar. | |
| llvm/include/llvm/Transforms/Vectorize/SLPVectorizer.h | ||
|---|---|---|
| 148–149 | I agree, something like iterator_range<T> makes it more explicit. Let me update the patch. | |
Why need a template here since looks like it accepts only ArrayRef?