[flang-commits] [flang] [flang][OpenMP] Implement collapse for imperfectly nested loops (PR #202435)

Krzysztof Parzyszek via flang-commits flang-commits at lists.llvm.org
Wed Jun 17 05:59:12 PDT 2026


================
@@ -111,6 +111,49 @@ class AssociatedLoopChecker {
   std::int64_t level_;
   std::map<std::string, std::int64_t> constructNamesAndLevels_;
 };
+
+/// Visitor that detects an ordered directive with a doacross clause
+/// (or the pre-5.2 depend(sink/source) equivalent).
+/// Does not descend into nested OpenMP block or loop constructs, since
+/// doacross directives inside them bind to an inner worksharing-loop
+/// region, not the one being checked.
+struct DoacrossFinder {
+  bool found{false};
+  template <typename T> bool Pre(const T &) { return !found; }
+  template <typename T> void Post(const T &) {}
+
+  // Stop descent into nested OpenMP regions that create new binding contexts.
+  bool Pre(const parser::OmpBlockConstruct &) { return false; }
+  bool Pre(const parser::OpenMPLoopConstruct &) { return false; }
----------------
kparzysz wrote:

Not all OpenMPLoopConstructs are worksharing-loop constructs (for example loop transforming constructs).

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


More information about the flang-commits mailing list