From b72646ab2a0a7d5dd84d0e6a0a869d4a0c0bed96 Mon Sep 17 00:00:00 2001 From: Jean Perier Date: Fri, 17 Oct 2025 07:22:33 -0700 Subject: [PATCH] [flang][OpenACC] add TODO for unstructured loops in acc loop directives --- flang/lib/Lower/OpenACC.cpp | 17 ++++++++++++++--- flang/test/Lower/OpenACC/acc-unstructured.f90 | 1 + 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/flang/lib/Lower/OpenACC.cpp b/flang/lib/Lower/OpenACC.cpp index cfb18914e8126..52503edabdbfc 100644 --- a/flang/lib/Lower/OpenACC.cpp +++ b/flang/lib/Lower/OpenACC.cpp @@ -2712,12 +2712,19 @@ genACC(Fortran::lower::AbstractConverter &converter, const auto &loopDirective = std::get(beginLoopDirective.t); + mlir::Location currentLocation = + converter.genLocation(beginLoopDirective.source); bool needEarlyExitHandling = false; - if (eval.lowerAsUnstructured()) + if (eval.lowerAsUnstructured()) { needEarlyExitHandling = hasEarlyReturn(eval); + // If the loop is lowered in an unstructured fashion, lowering generates + // explicit control flow that duplicates the looping semantics of the + // loops. + if (!needEarlyExitHandling) + TODO(currentLocation, + "loop with early exit inside OpenACC loop construct"); + } - mlir::Location currentLocation = - converter.genLocation(beginLoopDirective.source); Fortran::lower::StatementContext stmtCtx; assert(loopDirective.v == llvm::acc::ACCD_loop && @@ -3516,6 +3523,10 @@ genACC(Fortran::lower::AbstractConverter &converter, converter.genLocation(beginCombinedDirective.source); Fortran::lower::StatementContext stmtCtx; + if (eval.lowerAsUnstructured()) + TODO(currentLocation, + "loop with early exit inside OpenACC combined construct"); + if (combinedDirective.v == llvm::acc::ACCD_kernels_loop) { createComputeOp( converter, currentLocation, eval, semanticsContext, stmtCtx, diff --git a/flang/test/Lower/OpenACC/acc-unstructured.f90 b/flang/test/Lower/OpenACC/acc-unstructured.f90 index c57af98770cf5..c42c7dddc5ca1 100644 --- a/flang/test/Lower/OpenACC/acc-unstructured.f90 +++ b/flang/test/Lower/OpenACC/acc-unstructured.f90 @@ -1,4 +1,5 @@ ! RUN: bbc -fopenacc -emit-hlfir %s -o - | FileCheck %s +! XFAIL: * subroutine test_unstructured1(a, b, c) integer :: i, j, k