diff --git a/flang/lib/Lower/OpenMP/OpenMP.cpp b/flang/lib/Lower/OpenMP/OpenMP.cpp index d107c48a6422f..0b8b6edd501b3 100644 --- a/flang/lib/Lower/OpenMP/OpenMP.cpp +++ b/flang/lib/Lower/OpenMP/OpenMP.cpp @@ -2032,12 +2032,14 @@ static void createWsloop(Fortran::lower::AbstractConverter &converter, } } -static void createSimdWsloop( - Fortran::lower::AbstractConverter &converter, - Fortran::semantics::SemanticsContext &semaCtx, - Fortran::lower::pft::Evaluation &eval, llvm::omp::Directive ompDirective, - const Fortran::parser::OmpClauseList &beginClauseList, - const Fortran::parser::OmpClauseList *endClauseList, mlir::Location loc) { +static void +createSimdWsloop(Fortran::lower::AbstractConverter &converter, + Fortran::semantics::SemanticsContext &semaCtx, + Fortran::lower::pft::Evaluation &eval, + llvm::omp::Directive ompDirective, + const Fortran::parser::OmpClauseList &beginClauseList, + const Fortran::parser::OmpClauseList *endClauseList, + mlir::Location loc, DataSharingProcessor &dsp) { ClauseProcessor cp(converter, semaCtx, beginClauseList); cp.processTODO(loc, @@ -2050,7 +2052,6 @@ static void createSimdWsloop( // When support for vectorization is enabled, then we need to add handling of // if clause. Currently if clause can be skipped because we always assume // SIMD length = 1. - DataSharingProcessor dsp(converter, semaCtx, beginClauseList, eval); createWsloop(converter, semaCtx, eval, ompDirective, beginClauseList, endClauseList, loc, dsp); } @@ -2501,7 +2502,7 @@ static void genOMP(Fortran::lower::AbstractConverter &converter, if (llvm::omp::allDoSimdSet.test(ompDirective)) { // 2.9.3.2 Workshare SIMD construct createSimdWsloop(converter, semaCtx, eval, ompDirective, loopOpClauseList, - endClauseList, currentLocation); + endClauseList, currentLocation, dsp); } else if (llvm::omp::allSimdSet.test(ompDirective)) { // 2.9.3.1 SIMD construct diff --git a/flang/test/Lower/OpenMP/target_private.f90 b/flang/test/Lower/OpenMP/target_private.f90 index 98e3b79d035df..5d73d810c5e2d 100644 --- a/flang/test/Lower/OpenMP/target_private.f90 +++ b/flang/test/Lower/OpenMP/target_private.f90 @@ -28,3 +28,36 @@ subroutine omp_target_private !CHECK-NEXT: } end subroutine omp_target_private + +!CHECK-LABEL: func.func @_QPomp_target_target_do_simd() +subroutine omp_target_target_do_simd() + implicit none + + real(8) :: var + integer(8) :: iv + +!$omp target teams distribute parallel do simd private(iv,var) + do iv=0,10 + var = 3.14 + end do +!$omp end target teams distribute parallel do simd + +!CHECK: omp.target trip_count +!CHECK: fir.alloca f64 {bindc_name = "var", pinned +!CHECK: omp.teams { +!CHECK-NEXT: omp.distribute { +!CHECK-NEXT: omp.parallel { +!CHECK: fir.alloca i64 +!CHECK: omp.wsloop +!CHECK: omp.yield +!CHECK-NEXT: } +!CHECK-NEXT: omp.terminator +!CHECK-NEXT: } +!CHECK-NEXT: omp.terminator +!CHECK-NEXT: } +!CHECK-NEXT: omp.terminator +!CHECK-NEXT: } +!CHECK-NEXT: omp.terminator +!CHECK-NEXT: } + +end subroutine omp_target_target_do_simd