Skip to content

Commit c0d731e

Browse files
authored
[flang][OpenACC] add TODO for unstructured loops in acc loop directives (llvm#163972)
The lowering of `!$acc loop` loops with an early exit currently ends-up "duplicating" the control flow in the acc.loop and inside it as explicit control flow (as if each iteration executes each iteration until the early exit). Add a TODO for now.
1 parent 941d2fd commit c0d731e

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

flang/lib/Lower/OpenACC.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2717,12 +2717,19 @@ genACC(Fortran::lower::AbstractConverter &converter,
27172717
const auto &loopDirective =
27182718
std::get<Fortran::parser::AccLoopDirective>(beginLoopDirective.t);
27192719

2720+
mlir::Location currentLocation =
2721+
converter.genLocation(beginLoopDirective.source);
27202722
bool needEarlyExitHandling = false;
2721-
if (eval.lowerAsUnstructured())
2723+
if (eval.lowerAsUnstructured()) {
27222724
needEarlyExitHandling = hasEarlyReturn(eval);
2725+
// If the loop is lowered in an unstructured fashion, lowering generates
2726+
// explicit control flow that duplicates the looping semantics of the
2727+
// loops.
2728+
if (!needEarlyExitHandling)
2729+
TODO(currentLocation,
2730+
"loop with early exit inside OpenACC loop construct");
2731+
}
27232732

2724-
mlir::Location currentLocation =
2725-
converter.genLocation(beginLoopDirective.source);
27262733
Fortran::lower::StatementContext stmtCtx;
27272734

27282735
assert(loopDirective.v == llvm::acc::ACCD_loop &&
@@ -3521,6 +3528,10 @@ genACC(Fortran::lower::AbstractConverter &converter,
35213528
converter.genLocation(beginCombinedDirective.source);
35223529
Fortran::lower::StatementContext stmtCtx;
35233530

3531+
if (eval.lowerAsUnstructured())
3532+
TODO(currentLocation,
3533+
"loop with early exit inside OpenACC combined construct");
3534+
35243535
if (combinedDirective.v == llvm::acc::ACCD_kernels_loop) {
35253536
createComputeOp<mlir::acc::KernelsOp>(
35263537
converter, currentLocation, eval, semanticsContext, stmtCtx,

flang/test/Lower/OpenACC/acc-unstructured.f90

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s
2+
! XFAIL: *
23

34
subroutine test_unstructured1(a, b, c)
45
integer :: i, j, k

0 commit comments

Comments
 (0)