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

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Thu Mar 12 07:09:25 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() {
----------------
kparzysz wrote:

I've changed it to `precalculate`, in case there are more things to precalculate in the future.

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


More information about the flang-commits mailing list