Patch tries to improve two-pass vectorization analysis, existing in SLP vectorizer. What it does:
- Defines key nodes, that are the vectorization roots. Previously vectorization started if StoreInst or ReturnInst is found. For now, the vectorization started for all Instructions with no users and void types (Terminators, StoreInst) + CallInsts.
- CmpInsts, InsertElementInsts and InsertValueInsts are stored in the array. This array is processed only after the vectorization of the first-after-these instructions key node is finished. Vectorization goes in reverse order to try to vectorize as much code as possible.
This BinaryOperator->Instruction change (along with associated changes in tryToVectorizeHorReductionOrInstOperands and vectorizeRootInstruction) look like they can pulled out and committed without any problem.