[flang-commits] [flang] [flang][OpenACC] Skip non-loop evaluations when descending a collapsed/tiled DO nest (PR #223579)

Ron Green [NVIDIA] via flang-commits flang-commits at lists.llvm.org
Wed Sep 16 12:11:23 PDT 2026


ronGreenNV wrote:

Thanks for the review, @jeanPerier! Pushed 68b43834240a addressing both points:

**Positive list / TODO for unexpected nodes:** You're right that this was too permissive. `findNestedDoConstructEvaluation`'s skip loop collected every non-`DoConstruct` sibling with no diagnostic beyond the directive-specific warning, so anything genuinely unexpected would have been silently dropped — the same failure mode bug 4171 was about, just narrowed. Switched `diagnoseSkippedEvaluations` (renamed from `warnAboutSkippedDirectives`) to a positive list:
- The `NonLabelDoStmt` heading the level being searched is always present and is silently expected (it's a normal sibling of whatever comes next, not something to diagnose).
- A compiler directive is warned about, as before.
- Anything else now fails loudly with `TODO` instead of being discarded.

Worth noting while testing this: an ordinary statement between loop levels (e.g. a `PRINT`) is actually already rejected earlier, in semantic analysis ("Not enough perfectly nested loops for COLLAPSE(2) clause"), so a directive really is the only thing that can legitimately reach this code today. The `TODO` is there as a safety net for whatever else might slip through in a way I haven't found yet, rather than something I expect to fire in practice.

**Propagating $DIR to acc.loop:** Added a comment referencing #106522 and #216769 noting that a directive between inner loop levels can't be moved ahead of the construct the way outer-loop directives are, so it's only warned about for now, and that propagating it onto the acc.loop via the same `attachDirectiveToLoop` mechanism (rather than just warning) would be worth doing later. Not attempting that here, per your note.

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


More information about the flang-commits mailing list