[flang-commits] [flang] [Flang][OpenMP] Add semantic support for Loop Sequences and OpenMP loop fuse (PR #161213)
Ferran Toda via flang-commits
flang-commits at lists.llvm.org
Wed Oct 29 06:21:26 PDT 2025
================
@@ -2254,85 +2258,86 @@ void OmpAttributeVisitor::CheckPerfectNestAndRectangularLoop(
// Find the associated region by skipping nested loop-associated constructs
// such as loop transformations
const parser::NestedConstruct *innermostAssocRegion{nullptr};
- const parser::OpenMPLoopConstruct *innermostConstruct{&x};
- while (const auto &innerAssocStmt{
- std::get<std::optional<parser::NestedConstruct>>(
- innermostConstruct->t)}) {
- innermostAssocRegion = &(innerAssocStmt.value());
+ const parser::OpenMPLoopConstruct *innermostConstruct = &x;
+ auto &loopConsList =
+ std::get<std::list<parser::NestedConstruct>>(innermostConstruct->t);
+ for (auto &loopCons : loopConsList) {
+ innermostAssocRegion = &loopCons;
if (const auto *innerConstruct{
std::get_if<common::Indirection<parser::OpenMPLoopConstruct>>(
innermostAssocRegion)}) {
- innermostConstruct = &innerConstruct->value();
+ CheckPerfectNestAndRectangularLoop(innerConstruct->value());
+ return;
} else {
- break;
- }
- }
- if (!innermostAssocRegion)
- return;
- const auto &outer{std::get_if<parser::DoConstruct>(innermostAssocRegion)};
- if (!outer)
- return;
+ if (!innermostAssocRegion)
+ continue;
+ const auto &outer{std::get_if<parser::DoConstruct>(innermostAssocRegion)};
+ if (!outer)
+ continue;
- llvm::SmallVector<Symbol *> ivs;
- int curLevel{0};
- const parser::DoConstruct *loop{outer};
- while (true) {
- auto [iv, lb, ub, step] = GetLoopBounds(*loop);
-
- if (lb)
- checkExprHasSymbols(ivs, lb);
- if (ub)
- checkExprHasSymbols(ivs, ub);
- if (step)
- checkExprHasSymbols(ivs, step);
- if (iv) {
- if (auto *symbol{currScope().FindSymbol(iv->source)})
- ivs.push_back(symbol);
- }
+ llvm::SmallVector<Symbol *> ivs;
+ int curLevel{0};
+ const parser::DoConstruct *loop{outer};
+ while (true) {
+ auto [iv, lb, ub, step] = GetLoopBounds(*loop);
+
+ if (lb)
+ checkExprHasSymbols(ivs, lb);
----------------
NouTimbaler wrote:
This code was not written by me so I did not want to modify it (I just had to indent it). Should I add this change in this patch?
https://github.com/llvm/llvm-project/pull/161213
More information about the flang-commits
mailing list