[flang-commits] [flang] [flang] Allow `cycle` in `target teams distribute [simd]` (PR #145462)
Kareem Ergawy via flang-commits
flang-commits at lists.llvm.org
Mon Jun 23 22:46:58 PDT 2025
https://github.com/ergawy created https://github.com/llvm/llvm-project/pull/145462
flang incorrectly issues a semantic erorr when a `cycle` statement is used inside a `target teams distribute [simd]` associated loop. This is not prevented by the spec, therefore this PR allows such construct.
>From 266fe0db40d5aad868d371ddaf7a3d2d88a96aa0 Mon Sep 17 00:00:00 2001
From: ergawy <kareem.ergawy at amd.com>
Date: Tue, 24 Jun 2025 00:43:24 -0500
Subject: [PATCH] [flang] Allow `cycle` in `target teams distribute [simd]`
flang incorrectly issues a semantic erorr when a `cycle` statement is
used inside a `target teams distribute [simd]` associated loop. This is
not prevented by the spec, therefore this PR allows such construct.
---
flang/lib/Semantics/check-directive-structure.h | 2 ++
flang/test/Semantics/OpenMP/do05-positivecase.f90 | 14 ++++++++++++++
2 files changed, 16 insertions(+)
diff --git a/flang/lib/Semantics/check-directive-structure.h b/flang/lib/Semantics/check-directive-structure.h
index 4a4893fe805a2..b1bf3e550aebc 100644
--- a/flang/lib/Semantics/check-directive-structure.h
+++ b/flang/lib/Semantics/check-directive-structure.h
@@ -76,6 +76,8 @@ template <typename D> class NoBranchingEnforce {
case llvm::omp::Directive::OMPD_distribute_parallel_for:
case llvm::omp::Directive::OMPD_distribute_simd:
case llvm::omp::Directive::OMPD_distribute_parallel_for_simd:
+ case llvm::omp::Directive::OMPD_target_teams_distribute:
+ case llvm::omp::Directive::OMPD_target_teams_distribute_simd:
case llvm::omp::Directive::OMPD_target_teams_distribute_parallel_do:
case llvm::omp::Directive::
OMPD_target_teams_distribute_parallel_do_simd:
diff --git a/flang/test/Semantics/OpenMP/do05-positivecase.f90 b/flang/test/Semantics/OpenMP/do05-positivecase.f90
index 8481cb2fc2ca0..eda04610535c2 100644
--- a/flang/test/Semantics/OpenMP/do05-positivecase.f90
+++ b/flang/test/Semantics/OpenMP/do05-positivecase.f90
@@ -57,4 +57,18 @@ program omp_do
if(i<10) cycle
end do
!$omp end target teams distribute parallel do simd
+
+ !$omp target teams distribute
+ !DEF: /omp_do/OtherConstruct6/i (OmpPrivate, OmpPreDetermined) HostAssoc INTEGER(4)
+ do i=1,100
+ !REF: /omp_do/OtherConstruct6/i
+ if(i < 5) cycle
+ end do
+
+ !$omp target teams distribute simd
+ !DEF: /omp_do/OtherConstruct7/i (OmpLinear, OmpPreDetermined) HostAssoc INTEGER(4)
+ do i=1,100
+ !REF: /omp_do/OtherConstruct7/i
+ if(i < 5) cycle
+ end do
end program omp_do
More information about the flang-commits
mailing list