[VPlan] Use recursive traversal iterator in VPSlotTracker.

This patch simplifies VPSlotTracker by using the recursive traversal
iterator to traverse all blocks in a VPlan in reverse post-order when
numbering VPValues in a plan.

This depends on a fix to RPOT (D100169). It also extends the traversal
unit tests to check RPOT.

Reviewed By: a.elovikov

Differential Revision: https://reviews.llvm.org/D100176
This commit is contained in:
Florian Hahn 2021-04-27 12:21:27 +01:00
parent f818ec9dd1
commit 160e729cf0
No known key found for this signature in database
GPG Key ID: 61D7554B5CECDC0D
2 changed files with 9 additions and 27 deletions

View File

@ -1250,26 +1250,6 @@ void VPSlotTracker::assignSlot(const VPValue *V) {
Slots[V] = NextSlot++;
}
void VPSlotTracker::assignSlots(const VPBlockBase *VPBB) {
if (auto *Region = dyn_cast<VPRegionBlock>(VPBB))
assignSlots(Region);
else
assignSlots(cast<VPBasicBlock>(VPBB));
}
void VPSlotTracker::assignSlots(const VPRegionBlock *Region) {
ReversePostOrderTraversal<const VPBlockBase *> RPOT(Region->getEntry());
for (const VPBlockBase *Block : RPOT)
assignSlots(Block);
}
void VPSlotTracker::assignSlots(const VPBasicBlock *VPBB) {
for (const VPRecipeBase &Recipe : *VPBB) {
for (VPValue *Def : Recipe.definedValues())
assignSlot(Def);
}
}
void VPSlotTracker::assignSlots(const VPlan &Plan) {
for (const VPValue *V : Plan.VPExternalDefs)
@ -1278,7 +1258,13 @@ void VPSlotTracker::assignSlots(const VPlan &Plan) {
if (Plan.BackedgeTakenCount)
assignSlot(Plan.BackedgeTakenCount);
ReversePostOrderTraversal<const VPBlockBase *> RPOT(Plan.getEntry());
for (const VPBlockBase *Block : RPOT)
assignSlots(Block);
ReversePostOrderTraversal<
VPBlockRecursiveTraversalWrapper<const VPBlockBase *>>
RPOT(VPBlockRecursiveTraversalWrapper<const VPBlockBase *>(
Plan.getEntry()));
for (const VPBasicBlock *VPBB :
VPBlockUtils::blocksOnly<const VPBasicBlock>(RPOT))
for (const VPRecipeBase &Recipe : *VPBB)
for (VPValue *Def : Recipe.definedValues())
assignSlot(Def);
}

View File

@ -372,11 +372,7 @@ class VPSlotTracker {
DenseMap<const VPValue *, unsigned> Slots;
unsigned NextSlot = 0;
void assignSlots(const VPBlockBase *VPBB);
void assignSlots(const VPRegionBlock *Region);
void assignSlots(const VPBasicBlock *VPBB);
void assignSlot(const VPValue *V);
void assignSlots(const VPlan &Plan);
public: