[polly] [polly] Add profitability check for expanded region. (PR #96548)

Michael Kruse via llvm-commits llvm-commits at lists.llvm.org
Mon Jul 29 06:28:34 PDT 2024


================
@@ -1621,6 +1626,12 @@ void ScopDetection::findScops(Region &R) {
     if (!ExpandedR)
       continue;
 
+    if (!isRegionExpansionProfitable(*ExpandedR, LI)) {
+      removeCachedResults(*ExpandedR);
+      delete ExpandedR;
----------------
Meinersbur wrote:

This passes all the tests (after fixing the 3 new ones):
```c++
Region *ScopDetection::expandRegion(Region &R) {
  ...
  while (ExpandedRegion) {
     ...
  }

  if (LastValidRegion && !isRegionExpansionProfitable(*LastValidRegion, LI)) {
    POLLY_DEBUG(dbgs() << "Non-profitable region: "
                       << LastValidRegion->getNameStr() << "\n");
    removeCachedResults(*LastValidRegion.get());
    return nullptr;
  }

  POLLY_DEBUG({
    if (LastValidRegion)
      dbgs() << "\tto " << LastValidRegion->getNameStr() << "\n";
    else
      dbgs() << "\tExpanding " << R.getNameStr() << " failed\n";
  });

  return LastValidRegion.release();
}
```

https://github.com/llvm/llvm-project/pull/96548


More information about the llvm-commits mailing list