[llvm] r251267 - RegionInfo: Correctly expand regions

Tobias Grosser via llvm-commits llvm-commits at lists.llvm.org
Sun Oct 25 15:55:59 PDT 2015


Author: grosser
Date: Sun Oct 25 17:55:59 2015
New Revision: 251267

URL: http://llvm.org/viewvc/llvm-project?rev=251267&view=rev
Log:
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

Modified:
    llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h

Modified: llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h
URL: http://llvm.org/viewvc/llvm-project/llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h?rev=251267&r1=251266&r2=251267&view=diff
==============================================================================
--- llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h (original)
+++ llvm/trunk/include/llvm/Analysis/RegionInfoImpl.h Sun Oct 25 17:55:59 2015
@@ -444,16 +444,14 @@ typename Tr::RegionT *RegionBase<Tr>::ge
   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<Tr>::ge
   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);




More information about the llvm-commits mailing list