forked from OSchip/llvm-project
[LV] Assert if trying to sink replicate region into another region (NFC)
Currently sinking a replicate region into another replicate region is
not supported. Add an assert, to make the problem more obvious, should
it occur.
Discussed post-commit for ccebf7a109
.
This commit is contained in:
parent
01c26d4e04
commit
337d765282
|
@ -9116,25 +9116,30 @@ VPlanPtr LoopVectorizationPlanner::buildVPlanWithVPRecipes(
|
|||
VPRecipeBase *Sink = RecipeBuilder.getRecipe(Entry.first);
|
||||
VPRecipeBase *Target = RecipeBuilder.getRecipe(Entry.second);
|
||||
|
||||
auto GetReplicateRegion = [](VPRecipeBase *R) -> VPRegionBlock * {
|
||||
auto *Region =
|
||||
dyn_cast_or_null<VPRegionBlock>(R->getParent()->getParent());
|
||||
if (Region && Region->isReplicator())
|
||||
return Region;
|
||||
return nullptr;
|
||||
};
|
||||
|
||||
// If the target is in a replication region, make sure to move Sink to the
|
||||
// block after it, not into the replication region itself.
|
||||
if (auto *TargetRegion =
|
||||
dyn_cast_or_null<VPRegionBlock>(Target->getParent()->getParent())) {
|
||||
if (TargetRegion->isReplicator()) {
|
||||
assert(TargetRegion->getNumSuccessors() == 1 &&
|
||||
"Expected SESE region!");
|
||||
VPBasicBlock *NextBlock =
|
||||
cast<VPBasicBlock>(TargetRegion->getSuccessors().front());
|
||||
Sink->moveBefore(*NextBlock, NextBlock->getFirstNonPhi());
|
||||
continue;
|
||||
}
|
||||
if (auto *TargetRegion = GetReplicateRegion(Target)) {
|
||||
assert(TargetRegion->getNumSuccessors() == 1 && "Expected SESE region!");
|
||||
assert(!GetReplicateRegion(Sink) &&
|
||||
"cannot sink a region into another region yet");
|
||||
VPBasicBlock *NextBlock =
|
||||
cast<VPBasicBlock>(TargetRegion->getSuccessors().front());
|
||||
Sink->moveBefore(*NextBlock, NextBlock->getFirstNonPhi());
|
||||
continue;
|
||||
}
|
||||
|
||||
auto *SinkRegion =
|
||||
dyn_cast_or_null<VPRegionBlock>(Sink->getParent()->getParent());
|
||||
auto *SinkRegion = GetReplicateRegion(Sink);
|
||||
// Unless the sink source is in a replicate region, sink the recipe
|
||||
// directly.
|
||||
if (!SinkRegion || !SinkRegion->isReplicator()) {
|
||||
if (!SinkRegion) {
|
||||
Sink->moveAfter(Target);
|
||||
continue;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue