aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichael Kruse <llvm-project@meinersbur.de>2025-09-25 12:08:33 +0200
committerMichael Kruse <llvm-project@meinersbur.de>2025-09-25 12:08:33 +0200
commitd7ea10a6c8062ba486bff3353daf05833d614c8e (patch)
tree86a5b3831c8d11606b76c71c1935628407d1402f
parentf1f38a6d69910b6beb48e6202bef2c52181459ad (diff)
downloadllvm-users/meinersbur/flang_loopnest-checks.zip
llvm-users/meinersbur/flang_loopnest-checks.tar.gz
llvm-users/meinersbur/flang_loopnest-checks.tar.bz2
-rw-r--r--flang/lib/Semantics/resolve-directives.cpp28
1 files changed, 15 insertions, 13 deletions
diff --git a/flang/lib/Semantics/resolve-directives.cpp b/flang/lib/Semantics/resolve-directives.cpp
index 3cead60..be4b7f7 100644
--- a/flang/lib/Semantics/resolve-directives.cpp
+++ b/flang/lib/Semantics/resolve-directives.cpp
@@ -2201,8 +2201,8 @@ void OmpAttributeVisitor::CheckPerfectNestAndRectangularLoop(
auto boundExpr{semantics::AnalyzeExpr(context_, *bound)};
if (!boundExpr)
return;
- semantics::UnorderedSymbolSet boundSyms =
- evaluate::CollectSymbols(*boundExpr);
+ semantics::UnorderedSymbolSet boundSyms{
+ evaluate::CollectSymbols(*boundExpr)};
if (boundSyms.empty())
return;
for (Symbol *iv : ivs) {
@@ -2215,24 +2215,26 @@ void OmpAttributeVisitor::CheckPerfectNestAndRectangularLoop(
}
};
- // Skip over loop transformation directives
- const parser::OpenMPLoopConstruct *innerMostLoop = &x;
- const parser::NestedConstruct *innerMostNest = nullptr;
- while (auto &optLoopCons{
- std::get<std::optional<parser::NestedConstruct>>(innerMostLoop->t)}) {
- innerMostNest = &(optLoopCons.value());
- if (const auto *innerLoop{
+ // 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());
+ if (const auto *innerConstruct{
std::get_if<common::Indirection<parser::OpenMPLoopConstruct>>(
- innerMostNest)}) {
- innerMostLoop = &(innerLoop->value());
+ innermostAssocRegion)}) {
+ innermostConstruct = &innerConstruct->value();
} else {
break;
}
}
- if (!innerMostNest)
+ if (!innermostAssocRegion)
return;
- const auto &outer{std::get_if<parser::DoConstruct>(innerMostNest)};
+ const auto &outer{std::get_if<parser::DoConstruct>(innermostAssocRegion)};
if (!outer)
return;