[flang-commits] [flang] [flang][OpenMP] Don't check unlabelled `cycle` branching for target loops (PR #111656)

via flang-commits flang-commits at lists.llvm.org
Wed Oct 9 03:02:41 PDT 2024


llvmbot wrote:


<!--LLVM PR SUMMARY COMMENT-->

@llvm/pr-subscribers-flang-semantics

Author: Kareem Ergawy (ergawy)

<details>
<summary>Changes</summary>

Properly handles `cycle` branching inside target distribute loops.

---
Full diff: https://github.com/llvm/llvm-project/pull/111656.diff


2 Files Affected:

- (modified) flang/lib/Semantics/check-directive-structure.h (+2) 
- (modified) flang/test/Semantics/OpenMP/do05-positivecase.f90 (+15) 


``````````diff
diff --git a/flang/lib/Semantics/check-directive-structure.h b/flang/lib/Semantics/check-directive-structure.h
index a1aff52f3a6843..ee360161d351e6 100644
--- a/flang/lib/Semantics/check-directive-structure.h
+++ b/flang/lib/Semantics/check-directive-structure.h
@@ -74,6 +74,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_parallel_do:
+        case llvm::omp::Directive::OMPD_target_teams_distribute_parallel_do_simd:
           return;
         default:
           break;
diff --git a/flang/test/Semantics/OpenMP/do05-positivecase.f90 b/flang/test/Semantics/OpenMP/do05-positivecase.f90
index 3b512a5b4f25eb..5e1b1b86f72f61 100644
--- a/flang/test/Semantics/OpenMP/do05-positivecase.f90
+++ b/flang/test/Semantics/OpenMP/do05-positivecase.f90
@@ -42,4 +42,19 @@ program omp_do
   end do
   !$omp end parallel
 
+  !$omp target teams distribute parallel do
+  !DEF:/omp_do/OtherConstruct4/i (OmpPrivate ,OmpPreDetermined) HostAssoc INTEGER(4)
+  do i=1,100
+    !REF:/omp_do/OtherConstruct4/i
+    if(i<10) cycle
+  end do
+  !$omp end target teams distribute parallel do
+
+  !$omp target teams distribute parallel do simd
+  !DEF:/omp_do/OtherConstruct5/i (OmpLinear,OmpPreDetermined) HostAssoc INTEGER(4)
+  do i=1,100
+    !REF:/omp_do/OtherConstruct5/i
+    if(i<10) cycle
+  end do
+  !$omp end target teams distribute parallel do simd
 end program omp_do

``````````

</details>


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


More information about the flang-commits mailing list