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

Huihui Zhang via llvm-commits llvm-commits at lists.llvm.org
Thu Aug 1 16:47:14 PDT 2024


huihzhang wrote:

Thank you @Meinersbur for the review feedbacks!

I have pushed an update to check and reject if region expansion add any trailing non-loop blocks, with no following loops for potential loop fusion. Regardless of what these trailing non-loop blocks contain.

Please help take a look, let me know what you think? Thanks a lot!

/// a separate note ///
I will post a different patch to reject leading non-loop blocks. A quick try of this rejection below is affecting 141 polly unit tests.
```
@@ -1861,6 +1861,14 @@ bool ScopDetection::isValidRegion(DetectionContext &Context) {
     return false;
   }

+  // Reject if CurRegion has any leading non-loop blocks.
+  BasicBlock *Entry = CurRegion.getEntry();
+  Loop *L = LI.getLoopFor(Entry);
+  if (!L || !CurRegion.contains(L)) {
+    Context.IsInvalid = true;
+    return false;
+  }
+
   for (BasicBlock *Pred : predecessors(CurRegion.getEntry())) {
     Instruction *PredTerm = Pred->getTerminator();
     if (isa<IndirectBrInst>(PredTerm) || isa<CallBrInst>(PredTerm))
```


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


More information about the llvm-commits mailing list