Support SCoPs with multiple entry edges.
Regions that have multiple entry edges are very common. A simple if condition
yields e.g. such a region:
if
/ \
then else
\ /
for_region
This for_region contains two entry edges 'then' -> 'for_region' and 'else' -> 'for_region'.
Previously we scheduled the RegionSimplify pass to translate such regions into
simple regions. With this patch, we now support them natively when the region is
in -loop-simplify form, which means the entry block should not be a loop header.
Contributed by: Star Tan <tanmx_star@yeah.net>
llvm-svn: 179586
diff --git a/polly/lib/Analysis/ScopDetection.cpp b/polly/lib/Analysis/ScopDetection.cpp
index e2f2ec5..ffe2d8e 100644
--- a/polly/lib/Analysis/ScopDetection.cpp
+++ b/polly/lib/Analysis/ScopDetection.cpp
@@ -133,7 +133,7 @@
BADSCOP_STAT(AffFunc, "Expression not affine");
BADSCOP_STAT(Scalar, "Found scalar dependency");
BADSCOP_STAT(Alias, "Found base address alias");
-BADSCOP_STAT(SimpleRegion, "Region not simple");
+BADSCOP_STAT(SimpleLoop, "Loop not in -loop-simplify form");
BADSCOP_STAT(Other, "Others");
//===----------------------------------------------------------------------===//
@@ -549,15 +549,17 @@
return false;
}
+ if (!R.getEnteringBlock()){
+ Loop *L = LI->getLoopFor(R.getEntry());
+ if (L && !L->isLoopSimplifyForm())
+ INVALID(SimpleLoop, "Loop not in simplify form is invalid!");
+ }
+
// SCoP cannot contain the entry block of the function, because we need
// to insert alloca instruction there when translate scalar to array.
if (R.getEntry() == &(R.getEntry()->getParent()->getEntryBlock()))
INVALID(Other, "Region containing entry block of function is invalid!");
- // Only regions that have a single entry are allowed.
- if (!R.getEnteringBlock())
- INVALID(SimpleRegion, "Region has multiple entries: " << R.getNameStr());
-
if (!isValidExit(Context))
return false;