All phi-like recipes should be at the beginning of a VPBasicBlock with
no other recipes in between. Ensure that the recurrence-splicing recipe
is not added between phi-like recipes, but after them.
Details
Diff Detail
- Repository
- rG LLVM Github Monorepo
Event Timeline
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
9507 | Hmm, PrevRecipe cannot be a header phi because that would result in 2nd order recurrence (or greater); but it may be a phi of a replicated region? Should blends be excluded here? Curious to see a test... | |
9511 | How about setting the insertion point of Builder before creating the Op, instead of finding where to move it afterwards? |
Updated to set the insert point of the builder up-front, rather than moving the created recipies later. Also removed unnneded isPhi check.
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
9506 | This became an NFC patch, update its title and summary? |
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
9507 |
Ok I now what phi-like case I originally hit: if the previous value is an induction value! So I think we still need the special handling? |
Restore code to set insert point for phi-like recipes.
Relevant test is something like trunc_with_first_order_recurrence in
test/Transforms/LoopVectorize/induction.ll
ping :)
@Ayal does the clarification why this is needed make sense?
(from inline comment)
Ok I now what phi-like case I originally hit: if the previous value is an induction value! So I think we still need the special handling?
Clarification indeed makes sense, induction feeding a FOR should presumably be handled, not being a 2nd-order recurrence (SOR).
So we may indeed still need the special handling - along with special test(s); perhaps using i-1 inside a "for i" loop? Would also be good to address/exclude/cover non-header phis - of replicated regions and blends.
There should be test coverage already for those cases, in Transforms/LoopVectorize/induction.ll, which fails verification from D111302 without the current patch.
Would also be good to address/exclude/cover non-header phis - of replicated regions and blends.
Should those be included in this patch here?
ok; can a comment be added to these tests, mentioning that they exercise induction-feeding-a-FOR, and careful placement of the FOR splice?
Wonder how VPlan generated correct code, with splice placed in the midst of phi's(?)
Would also be good to address/exclude/cover non-header phis - of replicated regions and blends.
Should those be included in this patch here?
or left as a TODO?
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
9491–9501 | nit: can tentatively set VPBasicBlock *InsertBlock = PrevRecipe->getParent(); initially, and later override it with InsertBlock = cast<VPBasicBlock>(Region->getSingleSuccessor()); |
Done in the committed version. The issue in the test case were other induction recipes after the splice. The existing widenIntOrFpInduction inserts new phis at the beginning of the BB, so it did not cause any issues during actual codegen.
Would also be good to address/exclude/cover non-header phis - of replicated regions and blends.
Should those be included in this patch here?
or left as a TODO?
I did not add a TODO in the committed version, because unfortunately I am not sure where to best add one :(
llvm/lib/Transforms/Vectorize/LoopVectorize.cpp | ||
---|---|---|
9491–9501 | Done in the committed version, thanks! |
nit: can tentatively set
initially, and later override it with