tryToVectorize() method implements one of searching paths for vectorizable tree roots in SLP vectorizer,
specifically for binary and comparison operations. Order of making probes for various scalar pairs
was defined by its implementation: the instruction operands, then climb over one operand if
the instruction is its sole user and then perform same actions for another operand if previous
attempts failed. Problem with this approach is that among these options we can have more than a
single vectorizable tree candidate and it is not necessarily the one which encountered first.
Trying to build vectorizable tree for each possible combination for just evaluation is expensive.
But we already have lookahead heuristics mechanism which we use for finding best pick among
operands of commutative instructions. It calculates cumulative score for candidates in two
consecutive lanes. This patch introduces use of the heuristics for choosing the best pair among
several combinations. We only try one that looks as most promising for vectorization.
Additional benefit is that we reduce total number of vectorization trees built for probes
because we skip those looking non-profitable early.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Unit Tests
Event Timeline
Hi Valery, thanks for the patch. This looks good! Could you split it into 2 patches: one that renames lookahead heuristics (NFC) and the second (functional) one?
llvm/test/Transforms/SLPVectorizer/AArch64/invalid_type.ll | ||
---|---|---|
7 | Do you need to update this test? |
Hi Alexey,
yeah, will do that. I actually have it split locally exactly like you suggested.
llvm/test/Transforms/SLPVectorizer/AArch64/invalid_type.ll | ||
---|---|---|
7 | I added check for vector types at line 9176 so we now are not reaching emission of the remark. |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
1046–1047 | nit: It also holds the operands of a VL, so it is probably best to mention this here too. | |
2016 | nit: perhaps findBestRootPair ? | |
2018 | We could also have a separate max-depth limit for this, because I guess it will not ran as frequently as the other one, so we could have a higher depth if required. | |
9227 | nit: I think we can drop .hasValue(), if (!BestCandidate) should work fine. |
llvm/lib/Transforms/Vectorize/SLPVectorizer.cpp | ||
---|---|---|
1046–1047 | Hm, I'm not sure I understand what you mean here. You might be mislead by the way diff is shown here. | |
2016 | Thanks for suggestion. Will apply it with next rebase. | |
2018 | Will do. Any suggestion about option name? | |
9227 | sure |
nit: It also holds the operands of a VL, so it is probably best to mention this here too.