@@ -4177,6 +4177,24 @@ class VPBlockUtils {
41774177 return cast<BlockTy>(&Block);
41784178 });
41794179 }
4180+
4181+ // / Inserts \p BlockPtr on the edge between \p From and \p To. That is, update
4182+ // / \p From's successor to \p To to point to \p BlockPtr and \p To's
4183+ // / predecessor from \p From to \p BlockPtr. \p From and \p To are added to \p
4184+ // / BlockPtr's predecessors and successors respectively. There must be a
4185+ // / single edge between \p From and \p To.
4186+ static void insertOnEdge (VPBlockBase *From, VPBlockBase *To,
4187+ VPBlockBase *BlockPtr) {
4188+ auto &Successors = From->getSuccessors ();
4189+ auto &Predecessors = To->getPredecessors ();
4190+ assert (count (Successors, To) == 1 && count (Predecessors, From) == 1 &&
4191+ " must have single between From and To" );
4192+ unsigned SuccIdx = std::distance (Successors.begin (), find (Successors, To));
4193+ unsigned PredIx =
4194+ std::distance (Predecessors.begin (), find (Predecessors, From));
4195+ VPBlockUtils::connectBlocks (From, BlockPtr, -1 , SuccIdx);
4196+ VPBlockUtils::connectBlocks (BlockPtr, To, PredIx, -1 );
4197+ }
41804198};
41814199
41824200class VPInterleavedAccessInfo {
0 commit comments