Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 3 additions & 4 deletions flang/lib/Semantics/check-omp-structure.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -849,8 +849,6 @@ void OmpStructureChecker::CheckSIMDNest(const parser::OpenMPConstruct &c) {
// The only OpenMP constructs that can be encountered during execution of
// a simd region are the `atomic` construct, the `loop` construct, the `simd`
// construct and the `ordered` construct with the `simd` clause.
// TODO: Expand the check to include `LOOP` construct as well when it is
// supported.

// Check if the parent context has the SIMD clause
// Please note that we use GetContext() instead of GetContextParent()
Expand Down Expand Up @@ -893,14 +891,15 @@ void OmpStructureChecker::CheckSIMDNest(const parser::OpenMPConstruct &c) {
}
}
},
// Allowing SIMD construct
// Allowing SIMD and loop construct
[&](const parser::OpenMPLoopConstruct &c) {
const auto &beginLoopDir{
std::get<parser::OmpBeginLoopDirective>(c.t)};
const auto &beginDir{
std::get<parser::OmpLoopDirective>(beginLoopDir.t)};
if ((beginDir.v == llvm::omp::Directive::OMPD_simd) ||
(beginDir.v == llvm::omp::Directive::OMPD_do_simd)) {
(beginDir.v == llvm::omp::Directive::OMPD_do_simd) ||
(beginDir.v == llvm::omp::Directive::OMPD_loop)) {
eligibleSIMD = true;
}
},
Expand Down
15 changes: 15 additions & 0 deletions flang/test/Semantics/OpenMP/nested-simd.f90
Original file line number Diff line number Diff line change
Expand Up @@ -189,3 +189,18 @@ SUBROUTINE NESTED_BAD(N)


END SUBROUTINE NESTED_BAD

SUBROUTINE SIMD_LOOP(A, B, N)
REAL :: A(100), B(100)
INTEGER :: I, J, N

!$OMP SIMD
DO I = 1, N
!$OMP LOOP
DO J = 1, N
B(J) = B(J) + A(J)
END DO
!$OMP END LOOP
END DO
!$OMP END SIMD
END SUBROUTINE
Loading