This is an archive of the discontinued LLVM Phabricator instance.

[VPlan] Disconnect VPRegionBlock from successors in graph iterator(NFCI)
ClosedPublic

Authored by fhahn on Dec 21 2022, 3:26 PM.

Details

Summary

This updates the VPAllSuccessorsIterator to not connect the
VPRegionBlock itself to its successors. The successors are connected to
the exit block of the region. At the moment, this doesn't change any
exisint functionality.

But the new schema ensures the following property when used for
VPDominatorTree:

  1. Entry & exit blocks of regions dominate the successors of the region.

This allows for convenient checking of dominance between defs and uses
that are not defined in the same region. I will share a follow-up patch
to use it for the VPDominatorTree soon.

Depends on D140500.

Diff Detail

Event Timeline

fhahn created this revision.Dec 21 2022, 3:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 21 2022, 3:26 PM
fhahn requested review of this revision.Dec 21 2022, 3:26 PM
Herald added a project: Restricted Project. · View Herald TranscriptDec 21 2022, 3:26 PM
Ayal added inline comments.Jan 17 2023, 12:57 AM
llvm/lib/Transforms/Vectorize/VPlanCFG.h
148

nit: the Region blocks themselves are (continue to be) directly connected to their successors, it is how the iterate traverses successors of a region - as those of its exit blocks, only.

160

nit: worth commenting that null is returned if given block and all its parents have no successors. (Independent of this patch.)

198–199

This is fine as every region has an entry block, which is what this 1 represents, independent of how many successors R may have, if any.

So current VPAllSuccessorIterator visits successors of a region twice - once coming from the exit block and once coming from the region, and the latter is removed here? Is it possible to test that it iterates over blocks correctly?

nit: can define NumSuccessors after early exiting if Block is region, or set it to 1 for regions instead of early exiting.

nit: can set NumSuccessors to zero if !ParentWithSuccs, instead of Block->getNumSuccessors(). (Independent of this patch).

fhahn updated this revision to Diff 489772.Jan 17 2023, 4:48 AM
fhahn marked 2 inline comments as done.

Address latest comments and rebase on top of fixes for independent suggestions.

Ayal accepted this revision.Jan 17 2023, 4:59 AM

Looks good to me, thanks for adding the test!

llvm/lib/Transforms/Vectorize/VPlanCFG.h
193

nit: can comment that 'entry' is the 1 "successor".

This revision is now accepted and ready to land.Jan 17 2023, 4:59 AM
fhahn added a comment.Jan 17 2023, 7:57 AM

(submit pending comment responses I missed to submit earlier)

llvm/lib/Transforms/Vectorize/VPlanCFG.h
148

Thanks, I clarified the comment that this is limited to the iterator traversal.

160

Will do separately, thanks!

198–199

So current VPAllSuccessorIterator visits successors of a region twice - once coming from the exit block and once coming from the region, and the latter is removed here? Is it possible to test that it iterates over blocks correctly?

Added a test in 3632bf85079bc497993def427223e9d74389a659 that use the iterator on a region directly.

nit: can define NumSuccessors after early exiting if Block is region, or set it to 1 for regions instead of early exiting.

moved, thanks!

nit: can set NumSuccessors to zero if !ParentWithSuccs, instead of Block->getNumSuccessors(). (Independent of this patch).

done in c95138392a75021c98f53b423b29995cb8a3283b, thanks!

This revision was landed with ongoing or failed builds.Jan 18 2023, 7:03 AM
This revision was automatically updated to reflect the committed changes.
fhahn marked an inline comment as done.Jan 18 2023, 7:03 AM
fhahn added inline comments.
llvm/lib/Transforms/Vectorize/VPlanCFG.h
193

Done in the committed version.