VPWidenCanonicalIVRecipe does not create PHI instructions, so it does
not need to be placed in the phi section of a VPBasicBlock.
Discussed D113223.
Paths 
  |  Differential  D116473  
[VPlan] Don't consider VPWidenCanonicalIVRecipe phi-like. ClosedPublic Authored by fhahn on Jan 1 2022, 4:17 AM. 
Details Summary VPWidenCanonicalIVRecipe does not create PHI instructions, so it does Discussed D113223. 
Diff Detail 
 Event TimelineHerald added subscribers: tschuett, psnobl, rogfer01 and 2 others.  ·  View Herald TranscriptJan 1 2022, 4:17 AM fhahn added a child revision: D113223: [VPlan] Add VPCanonicalIVRecipe, partly retire createInductionVariable..Jan 1 2022, 4:17 AM 
 fhahn added inline comments. 
 Comment Actions This looks good to me, thanks! 
 This revision is now accepted and ready to land.Jan 2 2022, 12:54 AM This revision was landed with ongoing or failed builds.Jan 2 2022, 4:49 AM Closed by commit rGb1a333f0feb8: [VPlan] Don't consider VPWidenCanonicalIVRecipe phi-like. (authored by fhahn).  ·  Explain Why This revision was automatically updated to reflect the committed changes. fhahn marked an inline comment as done. 
Revision Contents 
 
Diff 396923 llvm/lib/Transforms/Vectorize/LoopVectorize.cpp
 
 llvm/lib/Transforms/Vectorize/VPlanValue.h
 llvm/test/Transforms/LoopVectorize/X86/x86-interleaved-accesses-masked-group.ll
 llvm/test/Transforms/LoopVectorize/pr46525-expander-insertpoint.ll
 llvm/test/Transforms/LoopVectorize/reduction-order.ll
 llvm/test/Transforms/LoopVectorize/select-reduction.ll
 llvm/test/Transforms/LoopVectorize/vplan-sink-scalars-and-merge.ll
  | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
How about ironing this a bit, while we're here, e.g.:
// Introduce the early-exit compare IV <= BTC to form header block mask. // This is used instead of IV < TC because TC may wrap, unlike BTC. // Start by constructing the desired canonical IV in the header block as its first non-phi instructions. assert(CM.foldTailByMasking() && "must fold the tail"); VPBasicBlock *HeaderVPBB = Plan->getEntry()->getEntryBasicBlock(); auto NewInsertionPoint = HeaderVPBB->getFirstNonPhi(); VPValue *IV = nullptr; if (Legal->getPrimaryInduction()) IV = Plan->getOrAddVPValue(Legal->getPrimaryInduction()); else { auto *IVRecipe = new VPWidenCanonicalIVRecipe(); HeaderVPBB->insert(IVRecipe, NewInsertionPoint); IV = IVRecipe; } assert(Builder.getInsertBlock() == HeaderVPBB && "..."); // if desired? VPBuilder::InsertPointGuard Guard(Builder); Builder.setInsertPoint(HeaderVPBB, NewInsertionPoint);