Skip to content

Commit a6c02ed

Browse files
authored
[flang][openacc] Keep CYCLE check for compute and data construct (#73897)
Unlike mentioned in #73839, some OpenACC construct still need the cycle branching check to be performed. This patch adds a list of construct where the check is not needed (loop and combined construct) and add tests to check where it is still needed.
1 parent 77b9fb2 commit a6c02ed

File tree

5 files changed

+63
-1
lines changed

5 files changed

+63
-1
lines changed

flang/lib/Semantics/check-directive-structure.h

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,17 @@ template <typename D> class NoBranchingEnforce {
7979
break;
8080
}
8181
} else if constexpr (std::is_same_v<D, llvm::acc::Directive>) {
82-
return; // OpenACC construct do not need check for unlabelled CYCLES
82+
switch ((llvm::acc::Directive)currentDirective_) {
83+
// exclude loop directives which do not need a check for unlabelled
84+
// CYCLES
85+
case llvm::acc::Directive::ACCD_loop:
86+
case llvm::acc::Directive::ACCD_kernels_loop:
87+
case llvm::acc::Directive::ACCD_parallel_loop:
88+
case llvm::acc::Directive::ACCD_serial_loop:
89+
return;
90+
default:
91+
break;
92+
}
8393
}
8494
CheckConstructNameBranching("CYCLE");
8595
}

flang/test/Semantics/OpenACC/acc-data.f90

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,19 @@ program openacc_data_validity
187187
!$acc data copy(aa) device_type(default) wait
188188
!$acc end data
189189

190+
do i = 1, 100
191+
!$acc data copy(aa)
192+
!ERROR: CYCLE to construct outside of DATA construct is not allowed
193+
if (i == 10) cycle
194+
!$acc end data
195+
end do
196+
197+
!$acc data copy(aa)
198+
do i = 1, 100
199+
if (i == 10) cycle
200+
end do
201+
!$acc end data
202+
190203
end program openacc_data_validity
191204

192205
module mod1

flang/test/Semantics/OpenACC/acc-kernels.f90

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,4 +144,17 @@ program openacc_kernels_validity
144144
end do
145145
!$acc end kernels
146146

147+
do i = 1, 100
148+
!$acc kernels
149+
!ERROR: CYCLE to construct outside of KERNELS construct is not allowed
150+
if (i == 10) cycle
151+
!$acc end kernels
152+
end do
153+
154+
!$acc kernels
155+
do i = 1, 100
156+
if (i == 10) cycle
157+
end do
158+
!$acc end kernels
159+
147160
end program openacc_kernels_validity

flang/test/Semantics/OpenACC/acc-parallel.f90

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,4 +142,17 @@ program openacc_parallel_validity
142142
end do
143143
!$acc end parallel
144144

145+
do i = 1, 100
146+
!$acc parallel
147+
!ERROR: CYCLE to construct outside of PARALLEL construct is not allowed
148+
if (i == 10) cycle
149+
!$acc end parallel
150+
end do
151+
152+
!$acc parallel
153+
do i = 1, 100
154+
if (i == 10) cycle
155+
end do
156+
!$acc end parallel
157+
145158
end program openacc_parallel_validity

flang/test/Semantics/OpenACC/acc-serial.f90

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,4 +166,17 @@ program openacc_serial_validity
166166
end do
167167
!$acc end serial
168168

169+
do i = 1, 100
170+
!$acc serial
171+
!ERROR: CYCLE to construct outside of SERIAL construct is not allowed
172+
if (i == 10) cycle
173+
!$acc end serial
174+
end do
175+
176+
!$acc serial
177+
do i = 1, 100
178+
if (i == 10) cycle
179+
end do
180+
!$acc end serial
181+
169182
end program openacc_serial_validity

0 commit comments

Comments
 (0)