[llvm-branch-commits] [flang] [flang][OpenMP] Implement nest depth calculation in LoopSequence (PR #185298)

Michael Kruse via llvm-branch-commits llvm-branch-commits at lists.llvm.org
Thu Mar 12 05:51:06 PDT 2026


================
@@ -806,16 +806,32 @@ std::unique_ptr<LoopSequence::Construct> LoopSequence::createConstructEntry(
 void LoopSequence::createChildrenFromRange(
     ExecutionPartIterator::IteratorType begin,
     ExecutionPartIterator::IteratorType end) {
+  // Create children. If there is zero or one, this LoopSequence could be
+  // a nest. If there are more, it could be a proper sequence. In the latter
+  // case any code between consecutive children must be "transparent".
   for (auto &code : BlockRange(begin, end, BlockRange::Step::Over)) {
     if (auto entry{createConstructEntry(code)}) {
       children_.push_back(LoopSequence(std::move(entry), allowAllLoops_));
+      if (!IsTransformableLoop(code)) {
+        hasInvalidIC_ = true;
+        hasOpaqueIC_ = true;
+      }
+    } else {
+      hasInvalidIC_ = hasInvalidIC_ || !IsValidInterveningCode(code);
+      hasOpaqueIC_ = hasOpaqueIC_ || !IsTransparentInterveningCode(code);
     }
   }
 }
 
+void LoopSequence::calculateEverything() {
----------------
Meinersbur wrote:

```suggestion
void LoopSequence::calculateExtends() {
```
"Everything" doesn't add anything. Could also be just `calculate()`. Other ideas: `DepthAndLength`, `Shape`, `Dimensions`.

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


More information about the llvm-branch-commits mailing list