[flang-commits] [flang] [flang][openacc] Do not check for unlabelled CYCLE branching (PR #73839)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Wed Nov 29 10:26:42 PST 2023
https://github.com/clementval updated https://github.com/llvm/llvm-project/pull/73839
>From 44f3fa43d50fd17b5e6d60407bac9cda9e155544 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Wed, 29 Nov 2023 10:21:41 -0800
Subject: [PATCH 1/2] [flang][openacc] Do not check for unlabelled CYCLE
branching
---
.../lib/Semantics/check-directive-structure.h | 33 +++++++++++--------
.../Semantics/OpenACC/acc-kernels-loop.f90 | 5 +++
flang/test/Semantics/OpenACC/acc-loop.f90 | 7 ++++
.../OpenACC/acc-parallel-loop-validity.f90 | 5 +++
.../Semantics/OpenACC/acc-serial-loop.f90 | 5 +++
5 files changed, 41 insertions(+), 14 deletions(-)
diff --git a/flang/lib/Semantics/check-directive-structure.h b/flang/lib/Semantics/check-directive-structure.h
index fec677500722e4c..b6a6b25764fa277 100644
--- a/flang/lib/Semantics/check-directive-structure.h
+++ b/flang/lib/Semantics/check-directive-structure.h
@@ -15,6 +15,7 @@
#include "flang/Common/enum-set.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
+#include <type_traits>
#include <unordered_map>
namespace Fortran::semantics {
@@ -62,20 +63,24 @@ template <typename D> class NoBranchingEnforce {
if (const auto &cycleName{cycleStmt.v}) {
CheckConstructNameBranching("CYCLE", cycleName.value());
} else {
- switch ((llvm::omp::Directive)currentDirective_) {
- // exclude directives which do not need a check for unlabelled CYCLES
- case llvm::omp::Directive::OMPD_do:
- case llvm::omp::Directive::OMPD_simd:
- case llvm::omp::Directive::OMPD_parallel_do:
- case llvm::omp::Directive::OMPD_parallel_do_simd:
- case llvm::omp::Directive::OMPD_distribute_parallel_do:
- case llvm::omp::Directive::OMPD_distribute_parallel_do_simd:
- case llvm::omp::Directive::OMPD_distribute_parallel_for:
- case llvm::omp::Directive::OMPD_distribute_simd:
- case llvm::omp::Directive::OMPD_distribute_parallel_for_simd:
- return;
- default:
- break;
+ if constexpr (std::is_same_v<D, llvm::omp::Directive>) {
+ switch ((llvm::omp::Directive)currentDirective_) {
+ // exclude directives which do not need a check for unlabelled CYCLES
+ case llvm::omp::Directive::OMPD_do:
+ case llvm::omp::Directive::OMPD_simd:
+ case llvm::omp::Directive::OMPD_parallel_do:
+ case llvm::omp::Directive::OMPD_parallel_do_simd:
+ case llvm::omp::Directive::OMPD_distribute_parallel_do:
+ case llvm::omp::Directive::OMPD_distribute_parallel_do_simd:
+ case llvm::omp::Directive::OMPD_distribute_parallel_for:
+ case llvm::omp::Directive::OMPD_distribute_simd:
+ case llvm::omp::Directive::OMPD_distribute_parallel_for_simd:
+ return;
+ default:
+ break;
+ }
+ } else if constexpr (std::is_same_v<D, llvm::acc::Directive>) {
+ return; // OpenACC construct do not need check for unlabelled CYCLES
}
CheckConstructNameBranching("CYCLE");
}
diff --git a/flang/test/Semantics/OpenACC/acc-kernels-loop.f90 b/flang/test/Semantics/OpenACC/acc-kernels-loop.f90
index 1a280f7c54f5cd3..8653978fb6249db 100644
--- a/flang/test/Semantics/OpenACC/acc-kernels-loop.f90
+++ b/flang/test/Semantics/OpenACC/acc-kernels-loop.f90
@@ -290,4 +290,9 @@ program openacc_kernels_loop_validity
a(i) = 3.14
end do
+ !$acc parallel loop
+ do i = 1, N
+ if(i == 10) cycle
+ end do
+
end program openacc_kernels_loop_validity
diff --git a/flang/test/Semantics/OpenACC/acc-loop.f90 b/flang/test/Semantics/OpenACC/acc-loop.f90
index ee1e6e0cce09740..f5d1e501a2b329d 100644
--- a/flang/test/Semantics/OpenACC/acc-loop.f90
+++ b/flang/test/Semantics/OpenACC/acc-loop.f90
@@ -276,4 +276,11 @@ program openacc_loop_validity
end do
end do
+ !$acc parallel
+ !$acc loop
+ do i = 1, n
+ if(i == 10) cycle
+ end do
+ !$acc end parallel
+
end program openacc_loop_validity
diff --git a/flang/test/Semantics/OpenACC/acc-parallel-loop-validity.f90 b/flang/test/Semantics/OpenACC/acc-parallel-loop-validity.f90
index b0be7d31e4426da..7f33f9e145110c4 100644
--- a/flang/test/Semantics/OpenACC/acc-parallel-loop-validity.f90
+++ b/flang/test/Semantics/OpenACC/acc-parallel-loop-validity.f90
@@ -136,4 +136,9 @@ program openacc_parallel_loop_validity
reduction_l = d(i) .neqv. e(i)
end do
+ !$acc parallel loop
+ do i = 1, N
+ if(i == 10) cycle
+ end do
+
end program openacc_parallel_loop_validity
diff --git a/flang/test/Semantics/OpenACC/acc-serial-loop.f90 b/flang/test/Semantics/OpenACC/acc-serial-loop.f90
index bef117b71f9312f..2832274680eca38 100644
--- a/flang/test/Semantics/OpenACC/acc-serial-loop.f90
+++ b/flang/test/Semantics/OpenACC/acc-serial-loop.f90
@@ -106,4 +106,9 @@ program openacc_serial_loop_validity
end do
!$acc end serial
+ !$acc serial loop
+ do i = 1, n
+ if(i == 10) cycle
+ end do
+
end program openacc_serial_loop_validity
>From 7ea0061125f9b4c3a8a5852e096a1a5a79a37cce Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Wed, 29 Nov 2023 10:26:22 -0800
Subject: [PATCH 2/2] Remove include
---
flang/lib/Semantics/check-directive-structure.h | 1 -
1 file changed, 1 deletion(-)
diff --git a/flang/lib/Semantics/check-directive-structure.h b/flang/lib/Semantics/check-directive-structure.h
index b6a6b25764fa277..7965fb595ff1bab 100644
--- a/flang/lib/Semantics/check-directive-structure.h
+++ b/flang/lib/Semantics/check-directive-structure.h
@@ -15,7 +15,6 @@
#include "flang/Common/enum-set.h"
#include "flang/Semantics/semantics.h"
#include "flang/Semantics/tools.h"
-#include <type_traits>
#include <unordered_map>
namespace Fortran::semantics {
More information about the flang-commits
mailing list