From aaf72bc7c6afd0ec80978baf3e6a2ca5b4011914 Mon Sep 17 00:00:00 2001 From: Tobias Grosser Date: Sun, 25 Oct 2015 22:55:59 +0000 Subject: [PATCH] RegionInfo: Correctly expand regions Instead of playing around with dominance to verify if the possible expansion of a scop region is indeed a single entry single exit region, we now distinguish two cases. In case we only append a basic block, all edges entering this basic block need to have come from within the region that is expanded. In case we join two regions, the source basic blocks of the edges that end at the entry node of the region that is appended most be part of either the original region or the region that is appended. This change will be tested through Polly. This fixes llvm.org/PR25242 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@251267 91177308-0d34-0410-b5e6-96231b3b80d8 --- include/llvm/Analysis/RegionInfoImpl.h | 24 ++++++++++-------------- 1 file changed, 10 insertions(+), 14 deletions(-) diff --git a/include/llvm/Analysis/RegionInfoImpl.h b/include/llvm/Analysis/RegionInfoImpl.h index 0598068d69d..134cd8f96fb 100644 --- a/include/llvm/Analysis/RegionInfoImpl.h +++ b/include/llvm/Analysis/RegionInfoImpl.h @@ -444,16 +444,14 @@ typename Tr::RegionT *RegionBase::getExpandedRegion() const { if (NumSuccessors == 0) return nullptr; - for (PredIterTy PI = InvBlockTraits::child_begin(getExit()), - PE = InvBlockTraits::child_end(getExit()); - PI != PE; ++PI) { - if (!DT->dominates(getEntry(), *PI)) - return nullptr; - } - RegionT *R = RI->getRegionFor(exit); if (R->getEntry() != exit) { + for (PredIterTy PI = InvBlockTraits::child_begin(getExit()), + PE = InvBlockTraits::child_end(getExit()); + PI != PE; ++PI) + if (!contains(*PI)) + return nullptr; if (Tr::getNumSuccessors(exit) == 1) return new RegionT(getEntry(), *BlockTraits::child_begin(exit), RI, DT); return nullptr; @@ -462,13 +460,11 @@ typename Tr::RegionT *RegionBase::getExpandedRegion() const { while (R->getParent() && R->getParent()->getEntry() == exit) R = R->getParent(); - if (!DT->dominates(getEntry(), R->getExit())) { - for (PredIterTy PI = InvBlockTraits::child_begin(getExit()), - PE = InvBlockTraits::child_end(getExit()); - PI != PE; ++PI) { - if (!DT->dominates(R->getExit(), *PI)) - return nullptr; - } + for (PredIterTy PI = InvBlockTraits::child_begin(getExit()), + PE = InvBlockTraits::child_end(getExit()); + PI != PE; ++PI) { + if (!(contains(*PI) || R->contains(*PI))) + return nullptr; } return new RegionT(getEntry(), R->getExit(), RI, DT); -- 2.34.1